Module: WCC::Contentful::ActiveRecordShim
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/wcc/contentful/active_record_shim.rb
Instance Method Summary collapse
- #attributes ⇒ Object
- #cache_key ⇒ Object
- #cache_key_with_version ⇒ Object
- #cache_key_without_version ⇒ Object
- #cache_version ⇒ Object
Instance Method Details
#attributes ⇒ Object
6 7 8 |
# File 'lib/wcc/contentful/active_record_shim.rb', line 6 def attributes @attributes ||= to_h['fields'].tap { |fields| fields['id'] = id } end |
#cache_key ⇒ Object
10 11 12 13 14 |
# File 'lib/wcc/contentful/active_record_shim.rb', line 10 def cache_key return cache_key_with_version unless ActiveRecord::Base.try(:cache_versioning) == true "#{self.class.model_name}/#{id}" end |
#cache_key_with_version ⇒ Object
16 17 18 |
# File 'lib/wcc/contentful/active_record_shim.rb', line 16 def cache_key_with_version "#{cache_key_without_version}-#{cache_version}" end |
#cache_key_without_version ⇒ Object
20 21 22 |
# File 'lib/wcc/contentful/active_record_shim.rb', line 20 def cache_key_without_version "#{self.class.model_name}/#{id}" end |
#cache_version ⇒ Object
24 25 26 |
# File 'lib/wcc/contentful/active_record_shim.rb', line 24 def cache_version sys.revision.to_s end |