Class: Yaks::Resource::Form

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

Defined Under Namespace

Classes: Field, Fieldset, Legend

Instance Method Summary collapse

Methods included from HasFields

#fields_flat, #map_fields

Instance Method Details

#[](name) ⇒ Object



7
8
9
# File 'lib/yaks/resource/form.rb', line 7

def [](name)
  fields.find {|field| field.name.equal? name}.value
end

#has_action?Boolean

rubocop:disable Style/PredicateName

Returns:

  • (Boolean)


21
22
23
# File 'lib/yaks/resource/form.rb', line 21

def has_action? # rubocop:disable Style/PredicateName
  !action.nil?
end

#method?(meth) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/yaks/resource/form.rb', line 17

def method?(meth)
  !method.nil? && method.downcase.to_sym == meth.downcase.to_sym
end

#valuesObject



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

def values
  fields_flat.each_with_object({}) do |field, values|
    values[field.name] = field.value
  end
end