Class: Pageflow::FileReuse
- Inherits:
-
Object
- Object
- Pageflow::FileReuse
- Defined in:
- app/models/pageflow/file_reuse.rb
Instance Attribute Summary collapse
-
#destination_entry ⇒ Object
Returns the value of attribute destination_entry.
-
#file ⇒ Object
Returns the value of attribute file.
-
#file_type ⇒ Object
Returns the value of attribute file_type.
-
#source_entry ⇒ Object
Returns the value of attribute source_entry.
Instance Method Summary collapse
-
#initialize(destination_entry, source_entry, file_type, file_id) ⇒ FileReuse
constructor
A new instance of FileReuse.
- #save! ⇒ Object
Constructor Details
#initialize(destination_entry, source_entry, file_type, file_id) ⇒ FileReuse
Returns a new instance of FileReuse.
5 6 7 8 9 10 |
# File 'app/models/pageflow/file_reuse.rb', line 5 def initialize(destination_entry, source_entry, file_type, file_id) @source_entry = source_entry @destination_entry = destination_entry @file_type = file_type @file = source_entry.find_file(file_type.model, file_id) end |
Instance Attribute Details
#destination_entry ⇒ Object
Returns the value of attribute destination_entry.
3 4 5 |
# File 'app/models/pageflow/file_reuse.rb', line 3 def destination_entry @destination_entry end |
#file ⇒ Object
Returns the value of attribute file.
3 4 5 |
# File 'app/models/pageflow/file_reuse.rb', line 3 def file @file end |
#file_type ⇒ Object
Returns the value of attribute file_type.
3 4 5 |
# File 'app/models/pageflow/file_reuse.rb', line 3 def file_type @file_type end |
#source_entry ⇒ Object
Returns the value of attribute source_entry.
3 4 5 |
# File 'app/models/pageflow/file_reuse.rb', line 3 def source_entry @source_entry end |
Instance Method Details
#save! ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/models/pageflow/file_reuse.rb', line 12 def save! destination_entry.use_file(file) file_type.nested_file_types.each do |nested_file_type| source_entry.find_files(nested_file_type.model).each do |nested_file| next if nested_file.parent_file_id != file.id || nested_file.parent_file_model_type != file.model_name.name destination_entry.use_file(nested_file) end end end |