Module: MapFields::ClassMethods

Defined in:
lib/map_fields.rb

Instance Method Summary collapse

Instance Method Details

#map_fields(action, fields, options = {}) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/map_fields.rb', line 13

def map_fields(action, fields, options = {})
  include MapFields::InstanceMethods
  write_inheritable_array("map_fields_fields_#{action}", fields)
  write_inheritable_attribute("map_fields_options_#{action}", options)
  write_inheritable_attribute(:map_fields_actions, []) unless read_inheritable_attribute(:map_fields_actions)
  write_inheritable_attribute(:map_fields_actions, (read_inheritable_attribute(:map_fields_actions) << action).uniq)
  skip_filter :map_fields
  skip_filter :map_fields_cleanup
  before_filter :map_fields, :only =>  read_inheritable_attribute(:map_fields_actions)
  after_filter :map_fields_cleanup, :only =>  read_inheritable_attribute(:map_fields_actions)
end