Module: CanTango::Model::Actions::ClassMethods

Defined in:
lib/cantango/model/actions.rb

Instance Method Summary collapse

Instance Method Details

#tango_actions(*actions) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/cantango/model/actions.rb', line 29

def tango_actions *actions
  action_clazz = self.name.underscore.to_sym
  options = actions.extract_options!
  clazz = CanTango::Model::Actions
  case options[:as]
  when :member
    clazz.register_member_actions action_clazz, *actions
  when :collection
    clazz.register_collection_actions action_clazz, *actions
  else
    raise ArgumentError, "You must specify a :to option as the last argument, of either :member or :collection"
  end
end