Module: PackRat::CacheHelper::ClassMethods

Defined in:
lib/pack_rat/cache_helper.rb

Instance Method Summary collapse

Instance Method Details

#file_digestObject



27
28
29
# File 'lib/pack_rat/cache_helper.rb', line 27

def file_digest
  @file_digest
end

#file_digest=(digest) ⇒ Object



30
31
32
# File 'lib/pack_rat/cache_helper.rb', line 30

def file_digest=(digest)
  @file_digest = digest
end

#file_locationObject



20
21
22
# File 'lib/pack_rat/cache_helper.rb', line 20

def file_location
  @file_location
end

#file_location=(path) ⇒ Object



23
24
25
26
# File 'lib/pack_rat/cache_helper.rb', line 23

def file_location=(path)
  @file_location = path
  generate_file_digest
end

#file_location_guesserObject



45
46
47
# File 'lib/pack_rat/cache_helper.rb', line 45

def file_location_guesser
  "#{Rails.root}/app/models/#{self.to_s.split('::').join('/').underscore.downcase}.rb" if defined? Rails
end

#generate_file_digestObject



34
35
36
37
38
39
40
41
42
43
# File 'lib/pack_rat/cache_helper.rb', line 34

def generate_file_digest
  if self.file_location
    begin
      file = File.read(self.file_location)
      self.file_digest = Digest::MD5.hexdigest(file)
    rescue
      self.file_digest = nil
    end
  end
end

#updated_attribute_nameObject



14
15
16
# File 'lib/pack_rat/cache_helper.rb', line 14

def updated_attribute_name
  @updated_attribute_name
end

#updated_attribute_name=(name) ⇒ Object



17
18
19
# File 'lib/pack_rat/cache_helper.rb', line 17

def updated_attribute_name=(name)
  @updated_attribute_name = name
end