Class: Pageflow::UsedFile
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Pageflow::UsedFile
- Defined in:
- app/models/pageflow/used_file.rb
Overview
rubocop:todo Style/Documentation
Constant Summary collapse
- USAGE_ATTRIBUTES =
[:configuration, :display_name, :folder_perma_id].freeze
Instance Method Summary collapse
- #cache_key ⇒ Object
- #cache_key_with_version ⇒ Object
- #class ⇒ Object
- #configuration ⇒ Object
- #display_name ⇒ Object
- #folder_perma_id ⇒ 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
36 37 38 |
# File 'app/models/pageflow/used_file.rb', line 36 def cache_key [@file.cache_key, @usage.cache_key].join('-') end |
#cache_key_with_version ⇒ Object
40 41 42 |
# File 'app/models/pageflow/used_file.rb', line 40 def cache_key_with_version [@file.cache_key_with_version, @usage.cache_key_with_version].join('-') end |
#class ⇒ Object
51 52 53 |
# File 'app/models/pageflow/used_file.rb', line 51 def class @file.class end |
#configuration ⇒ Object
9 10 11 |
# File 'app/models/pageflow/used_file.rb', line 9 def configuration @usage.configuration end |
#display_name ⇒ Object
28 29 30 |
# File 'app/models/pageflow/used_file.rb', line 28 def display_name @usage.display_name end |
#folder_perma_id ⇒ Object
32 33 34 |
# File 'app/models/pageflow/used_file.rb', line 32 def folder_perma_id @usage.folder_perma_id end |
#is_a?(klass) ⇒ Boolean
Not delegated by default. Required to allow using instances in Active Record conditions.
47 48 49 |
# File 'app/models/pageflow/used_file.rb', line 47 def is_a?(klass) @file.is_a?(klass) end |
#perma_id ⇒ Object
24 25 26 |
# File 'app/models/pageflow/used_file.rb', line 24 def perma_id @usage.perma_id end |
#update!(attributes) ⇒ Object
15 16 17 18 |
# File 'app/models/pageflow/used_file.rb', line 15 def update!(attributes) super(attributes.except(*USAGE_ATTRIBUTES)) @usage.update!(attributes.slice(*USAGE_ATTRIBUTES)) end |
#usage_id ⇒ Object
20 21 22 |
# File 'app/models/pageflow/used_file.rb', line 20 def usage_id @usage.id end |