Module: PackRat::CacheHelper::ClassMethods
- Defined in:
- lib/pack_rat/cache_helper.rb
Instance Method Summary collapse
-
#file_digest ⇒ Object
Stores the MD5 Digest of the class.
- #file_digest=(digest) ⇒ Object
-
#file_location ⇒ Object
File path of the class.
- #file_location=(path) ⇒ Object
-
#file_location_guesser ⇒ Object
Uses Rails conventions to determine location of the defined class.
-
#generate_file_digest ⇒ Object
Creates MD5 Digest of the set file_location attribute.
-
#updated_attribute_name ⇒ Object
Instance attribute name that stores the last time the object was updated, usually :updated_at.
- #updated_attribute_name=(name) ⇒ Object
Instance Method Details
#file_digest ⇒ Object
Stores the MD5 Digest of the class
34 35 36 |
# File 'lib/pack_rat/cache_helper.rb', line 34 def file_digest @file_digest end |
#file_digest=(digest) ⇒ Object
37 38 39 |
# File 'lib/pack_rat/cache_helper.rb', line 37 def file_digest=(digest) @file_digest = digest end |
#file_location ⇒ Object
File path of the class
25 26 27 |
# File 'lib/pack_rat/cache_helper.rb', line 25 def file_location @file_location end |
#file_location=(path) ⇒ Object
28 29 30 31 |
# File 'lib/pack_rat/cache_helper.rb', line 28 def file_location=(path) @file_location = path generate_file_digest end |
#file_location_guesser ⇒ Object
Uses Rails conventions to determine location of the defined class
54 55 56 57 58 59 |
# File 'lib/pack_rat/cache_helper.rb', line 54 def file_location_guesser # This needs to be refactored to take a prefix to replace the rails/app/models # AR Extension would be then include a prefix that this picks up # Haven't decided on a clean way to implement this "#{Rails.root}/app/models/#{self.to_s.split('::').join('/').underscore.downcase}.rb" if defined? Rails end |
#generate_file_digest ⇒ Object
Creates MD5 Digest of the set file_location attribute
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/pack_rat/cache_helper.rb', line 42 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_name ⇒ Object
Instance attribute name that stores the last time the object was updated, usually :updated_at
17 18 19 |
# File 'lib/pack_rat/cache_helper.rb', line 17 def updated_attribute_name @updated_attribute_name end |
#updated_attribute_name=(name) ⇒ Object
20 21 22 |
# File 'lib/pack_rat/cache_helper.rb', line 20 def updated_attribute_name=(name) @updated_attribute_name = name end |