Class: SweetActions::ActionFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/sweet_actions/action_factory.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(controller, action_name) ⇒ ActionFactory

Returns a new instance of ActionFactory.



5
6
7
8
9
10
11
# File 'lib/sweet_actions/action_factory.rb', line 5

def initialize(controller, action_name)
  @controller = controller
  path_parameters = env['action_dispatch.request.path_parameters']
  @resource_name = path_parameters[:resource_name]
  @action = action_name
  @namespace = path_parameters[:namespace]
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



3
4
5
# File 'lib/sweet_actions/action_factory.rb', line 3

def action
  @action
end

#controllerObject (readonly)

Returns the value of attribute controller.



3
4
5
# File 'lib/sweet_actions/action_factory.rb', line 3

def controller
  @controller
end

#namespaceObject (readonly)

Returns the value of attribute namespace.



3
4
5
# File 'lib/sweet_actions/action_factory.rb', line 3

def namespace
  @namespace
end

#resource_nameObject (readonly)

Returns the value of attribute resource_name.



3
4
5
# File 'lib/sweet_actions/action_factory.rb', line 3

def resource_name
  @resource_name
end

Instance Method Details

#build_actionObject



13
14
15
# File 'lib/sweet_actions/action_factory.rb', line 13

def build_action
  action_class.new(controller)
end