Module: Attach::ModelExtension::ClassMethods
- Defined in:
- lib/attach/model_extension/class_methods.rb
Instance Method Summary collapse
- #attachment(name, **options, &block) ⇒ Object
- #attachment_processors ⇒ Object
- #attachment_validators ⇒ Object
- #includes_attachment(*args, **options) ⇒ Object
Instance Method Details
#attachment(name, **options, &block) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/attach/model_extension/class_methods.rb', line 25 def (name, **, &block) setup_model parse_dsl(name, &block) define_method name do (name) end define_method "#{name}=" do |file| (name, file, **) end define_method "#{name}_delete" do instance_variable_get("@#{name}_delete") end define_method "#{name}_delete=" do |delete| delete = delete.to_i instance_variable_set("@#{name}_delete", delete) if delete == 1 @pending_attachment_deletions ||= [] @pending_attachment_deletions << name end end end |
#attachment_processors ⇒ Object
21 22 23 |
# File 'lib/attach/model_extension/class_methods.rb', line 21 def @attachment_processors ||= {} end |
#attachment_validators ⇒ Object
17 18 19 |
# File 'lib/attach/model_extension/class_methods.rb', line 17 def @attachment_validators ||= {} end |