Module: MotionModel::InputHelpers::ClassMethods

Defined in:
lib/motion_model/input_helpers.rb

Instance Method Summary collapse

Instance Method Details

#field(field, options = {}) ⇒ Object

field is a declarative macro that specifies the field name (i.e., the model field name) and the label. In the absence of a label, field attempts to synthesize one from the model field name. YMMV.

Usage:

class MyInputSheet < UIViewController
  include InputHelpers

  field 'event_name', :label => 'name'
  field 'event_location', :label => 'location

Only one field mapping may be supplied for a given class.



39
40
41
42
# File 'lib/motion_model/input_helpers.rb', line 39

def field(field, options = {})
  label = options[:label] || field.humanize
  @binding_data << FieldBindingMap.new(:label => label, :name => field)
end