From 5c3e8952bc2cd90526bf307eb002085d6ac1552a Mon Sep 17 00:00:00 2001 From: hassaku Date: Wed, 7 Jan 2015 12:40:27 +0900 Subject: [PATCH] Fix to define file_path_of as class method. --- .../fluentd/setting_archive/archivable.rb | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) 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