Method: Trust::Controller::Properties#actions

Defined in:
lib/trust/controller/properties.rb

#actions(options) ⇒ Object

Specify actions to handle

Options

:new => actions        # specify new actions - default id :new, :create
:member => actions     # specify member actions - default is :show, :edit, :update, :destroy
:collection => actions # specify collection actions - default is :index
:except => actions     # removes any standard actions
:only => actions       # selects only the standard actions specifiec
:add => {options}      # to add options, eg  :add => {:new => :confirm}


130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# File 'lib/trust/controller/properties.rb', line 130

def actions(options)
  if add = options[:add]
    self.new_actions += Array.wrap(add[:new]) if add[:new]
    self.member_actions += Array.wrap(add[:member]) if add[:member]
    self.collection_actions += Array.wrap(add[:collection]) if add[:collection]
  end
  self.new_actions = Array.wrap(options[:new]) if options[:new]
  self.member_actions = Array.wrap(options[:member]) if options[:member]
  self.collection_actions = Array.wrap(options[:collection]) if options[:collection]
  if options[:only]
    only = Array.wrap(options[:only])
    self.new_actions &= only
    self.member_actions &= only
    self.collection_actions &= only
  end
  if options[:except]
    except = Array.wrap(options[:except])
    self.new_actions -= except
    self.member_actions -= except
    self.collection_actions -= except
  end
end