Class: Yaks::Resource::Form::Field

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

Defined Under Namespace

Classes: Option

Instance Method Summary collapse

Instance Method Details

#valueObject



8
9
10
11
12
13
14
15
# File 'lib/yaks/resource/form/field.rb', line 8

def value
  if type.equal? :select
    selected = options.find(&:selected)
    selected.value if selected
  else
    @value
  end
end

#with_value(value) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/yaks/resource/form/field.rb', line 17

def with_value(value)
  if type.equal? :select
    with(options: select_options_for_value(value))
  else
    with(value: value)
  end
end