Module: Sunrise::FileUpload::ActiveRecord::InstanceMethods
- Defined in:
- lib/sunrise/file_upload/active_record.rb
Instance Method Summary collapse
-
#fileupload_asset(method) ⇒ Object
Find or build new asset object.
- #fileupload_changed? ⇒ Boolean
-
#fileupload_guid ⇒ Object
Generate unique key.
- #fileupload_guid=(value) ⇒ Object
- #fileupload_multiple?(method) ⇒ Boolean
- #fileuploads_columns ⇒ Object
Instance Method Details
#fileupload_asset(method) ⇒ Object
Find or build new asset object
73 74 75 76 77 78 79 |
# File 'lib/sunrise/file_upload/active_record.rb', line 73 def fileupload_asset(method) if fileuploads_columns.include?(method.to_sym) asset = new_record? ? self.class.fileupload_find(method, fileupload_guid) : send(method) asset ||= send("build_#{method}") if respond_to?("build_#{method}") asset end end |
#fileupload_changed? ⇒ Boolean
63 64 65 |
# File 'lib/sunrise/file_upload/active_record.rb', line 63 def fileupload_changed? @fileupload_changed end |
#fileupload_guid ⇒ Object
Generate unique key
54 55 56 |
# File 'lib/sunrise/file_upload/active_record.rb', line 54 def fileupload_guid @fileupload_guid ||= Sunrise::FileUpload.guid end |
#fileupload_guid=(value) ⇒ Object
58 59 60 61 |
# File 'lib/sunrise/file_upload/active_record.rb', line 58 def fileupload_guid=(value) @fileupload_changed = true unless value.blank? @fileupload_guid = value.blank? ? nil : value end |
#fileupload_multiple?(method) ⇒ Boolean
67 68 69 70 |
# File 'lib/sunrise/file_upload/active_record.rb', line 67 def fileupload_multiple?(method) association = self.class.reflect_on_association(method) association.collection? end |
#fileuploads_columns ⇒ Object
81 82 83 |
# File 'lib/sunrise/file_upload/active_record.rb', line 81 def fileuploads_columns self.class.fileuploads_columns end |