diff --git a/app/models/concerns/fluentd/setting_archive/archivable.rb b/app/models/concerns/fluentd/setting_archive/archivable.rb index db34798..fa530f4 100644 --- a/app/models/concerns/fluentd/setting_archive/archivable.rb +++ b/app/models/concerns/fluentd/setting_archive/archivable.rb @@ -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