Class: Para::ModelFieldParsers::Paperclip
- Inherits:
-
Base
- Object
- Base
- Para::ModelFieldParsers::Paperclip
show all
- Defined in:
- lib/para/model_field_parsers/paperclip.rb
Instance Attribute Summary
Attributes inherited from Base
#fields_hash, #model
Instance Method Summary
collapse
Methods inherited from Base
#initialize, register
Instance Method Details
#applicable? ⇒ Boolean
25
26
27
|
# File 'lib/para/model_field_parsers/paperclip.rb', line 25
def applicable?
model.respond_to?(:attachment_definitions)
end
|
#parse! ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/para/model_field_parsers/paperclip.rb', line 6
def parse!
model.attachment_definitions.each do |key, options|
paperclip_suffixes.each do |suffix|
field_name = [key, suffix].join('_').to_sym
@fields_hash.delete(field_name)
end
@fields_hash[key] = if image?(options)
AttributeField::ImageField.new(
model, name: key, type: 'image', field_type: 'image'
)
else
AttributeField::FileField.new(
model, name: key, type: 'file', field_type: 'file'
)
end
end
end
|