Class: Pageflow::UsedFile
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Pageflow::UsedFile
- Defined in:
- app/models/pageflow/used_file.rb
Instance Method Summary collapse
- #cache_key ⇒ Object
- #cache_key_with_version ⇒ Object
- #class ⇒ Object
- #configuration ⇒ Object
-
#initialize(file, usage = nil) ⇒ UsedFile
constructor
A new instance of UsedFile.
-
#is_a?(klass) ⇒ Boolean
Not delegated by default.
- #perma_id ⇒ Object
- #update!(attributes) ⇒ Object
- #usage_id ⇒ Object
Constructor Details
#initialize(file, usage = nil) ⇒ UsedFile
Returns a new instance of UsedFile.
3 4 5 6 7 |
# File 'app/models/pageflow/used_file.rb', line 3 def initialize(file, usage = nil) super(file) @file = file @usage = usage || file.usages.first end |
Instance Method Details
#cache_key ⇒ Object
26 27 28 |
# File 'app/models/pageflow/used_file.rb', line 26 def cache_key [@file.cache_key, @usage.cache_key].join('-') end |
#cache_key_with_version ⇒ Object
30 31 32 |
# File 'app/models/pageflow/used_file.rb', line 30 def cache_key_with_version [@file.cache_key_with_version, @usage.cache_key_with_version].join('-') end |
#class ⇒ Object
41 42 43 |
# File 'app/models/pageflow/used_file.rb', line 41 def class @file.class end |
#configuration ⇒ Object
9 10 11 |
# File 'app/models/pageflow/used_file.rb', line 9 def configuration @usage.configuration end |
#is_a?(klass) ⇒ Boolean
Not delegated by default. Required to allow using instances in Active Record conditions.
37 38 39 |
# File 'app/models/pageflow/used_file.rb', line 37 def is_a?(klass) @file.is_a?(klass) end |
#perma_id ⇒ Object
22 23 24 |
# File 'app/models/pageflow/used_file.rb', line 22 def perma_id @usage.perma_id end |
#update!(attributes) ⇒ Object
13 14 15 16 |
# File 'app/models/pageflow/used_file.rb', line 13 def update!(attributes) super(attributes.except(:configuration)) @usage.update!(attributes.slice(:configuration)) end |
#usage_id ⇒ Object
18 19 20 |
# File 'app/models/pageflow/used_file.rb', line 18 def usage_id @usage.id end |