Module: Reform::Form::ActiveModel::ClassMethods

Defined in:
lib/reform/form/active_model.rb

Instance Method Summary collapse

Instance Method Details

#model(*args) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/reform/form/active_model.rb', line 9

def model(*args)
  @model_options  = args  # FIXME: make inheritable!
  main_model      = args.last[:on]

  delegate main_model, :to => :model  # #song => model.song
  delegate :persisted?, :to_key, :to_param, :to => main_model  # #to_key => song.to_key

  alias_method args.first, main_model # #hit => model.song.
end

#model_nameObject



24
25
26
# File 'lib/reform/form/active_model.rb', line 24

def model_name
  ::ActiveModel::Name.new(self, nil, @model_options.first.to_s.camelize)
end

#property(name, options = {}) ⇒ Object



19
20
21
22
# File 'lib/reform/form/active_model.rb', line 19

def property(name, options={})
  delegate options[:on], :to => :model
  super
end