Fix to define file_path_of as class method.

This commit is contained in:
hassaku 2015-01-07 12:40:27 +09:00
parent a28b71084c
commit 5c3e8952bc

View File

@ -1,8 +1,19 @@
class Fluentd
module SettingArchive
module Archivable
extend ActiveSupport::Concern
attr_accessor :file_path
module ClassMethods
private
def file_path_of(dir, id)
file_path = Pathname.new(dir).join("#{id}#{self::FILE_EXTENSION}")
raise "No such a file #{file_path}" unless File.exist?(file_path)
file_path
end
end
def file_id
@file_id ||= with_file { name.gsub(/#{self.class::FILE_EXTENSION}\Z/,'') }
end
@ -21,12 +32,6 @@ class Fluentd
private
def file_path_of(dir, id)
file_path = Pathname.new(dir).join("#{id}#{self.class::FILE_EXTENSION}")
raise "No such a file #{file_path}" unless File.exist?(file_path)
file_path
end
def with_file
return nil unless file_path && File.exist?(file_path)
yield