Module: AdminAssistant::ControllerClassMethods

Defined in:
lib/admin_assistant.rb

Instance Method Summary collapse

Instance Method Details

#admin_assistant_for(model_class, &block) ⇒ Object



218
219
220
221
222
223
224
225
226
227
228
229
230
231
# File 'lib/admin_assistant.rb', line 218

def admin_assistant_for(model_class, &block)
  self.admin_assistant = AdminAssistant.new(self, model_class)
  builder = Builder.new self.admin_assistant
  if block
    block.call builder
  end
  self.helper AdminAssistant::Helper
  self.admin_assistant.controller_actions.each do |action|
    self.send(:define_method, action) do
      self.class.admin_assistant.send(action, self)
    end
  end
  AdminAssistant.routes << Route.new(self.admin_assistant)
end