Class: Yaks::Mapper::Form
- Inherits:
-
Object
- Object
- Yaks::Mapper::Form
- Extended by:
- Forwardable, Util
- Defined in:
- lib/yaks/mapper/form.rb,
lib/yaks/mapper/form/field.rb,
lib/yaks/mapper/form/config.rb,
lib/yaks/mapper/form/legend.rb,
lib/yaks/mapper/form/fieldset.rb,
lib/yaks/mapper/form/field/option.rb,
lib/yaks/mapper/form/dynamic_field.rb
Defined Under Namespace
Classes: Config, DynamicField, Field, Fieldset, Legend
Class Method Summary collapse
Instance Method Summary collapse
Methods included from Util
Resolve, camelize, extract_options, reject_keys, slice_hash, symbolize_keys, underscore
Class Method Details
Instance Method Details
#add_to_resource(resource, mapper, _context) ⇒ Object
20 21 22 23 |
# File 'lib/yaks/mapper/form.rb', line 20 def add_to_resource(resource, mapper, _context) return resource if config.if && !mapper.(config.if) resource.add_form(to_resource_form(mapper)) end |
#to_resource_form(mapper) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/yaks/mapper/form.rb', line 25 def to_resource_form(mapper) attrs = { fields: config.to_resource_fields(mapper), action: mapper.(action) } [:name, :title, :method, :media_type].each do |attr| attrs[attr] = mapper.(public_send(attr)) end Resource::Form.new(attrs) end |