Class: Yaks::Mapper::Form::Field::Option

Inherits:
Object
  • Object
show all
Defined in:
lib/yaks/mapper/form/field/option.rb

Overview

<option>, as used in a <select>

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.create(value, opts) ⇒ Object



9
10
11
# File 'lib/yaks/mapper/form/field/option.rb', line 9

def self.create(value, opts)
  new(opts.merge(value: value))
end

Instance Method Details

#to_resource_field_option(mapper) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/yaks/mapper/form/field/option.rb', line 13

def to_resource_field_option(mapper)
  return unless self.if.nil? || mapper.expand_value(self.if)

  Resource::Form::Field::Option.new(
    value: mapper.expand_value(value),
    label: mapper.expand_value(label),
    selected: mapper.expand_value(selected),
    disabled: mapper.expand_value(disabled)
  )
end