Class: Lotus::Routing::Resource::Action Private
- Inherits:
-
Object
- Object
- Lotus::Routing::Resource::Action
- Includes:
- Utils::ClassAttribute
- Defined in:
- lib/lotus/routing/resource/action.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Action for RESTful resource
Direct Known Subclasses
CollectionAction, Create, Destroy, Edit, New, Show, Update, Lotus::Routing::Resources::Action
Constant Summary collapse
- NESTED_ROUTES_SEPARATOR =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Nested routes separator
'/'.freeze
Class Method Summary collapse
-
.generate(router, action, options = {}, resource = nil) ⇒ Object
private
Generate an action for the given router.
Instance Method Summary collapse
-
#generate(&blk) ⇒ Object
private
Generate an action for the given router.
-
#initialize(router, options = {}, resource = nil, &blk) ⇒ Action
constructor
private
Initialize an action.
-
#namespace ⇒ Object
private
Namespace.
-
#resource_name ⇒ String
private
Resource name.
Constructor Details
#initialize(router, options = {}, resource = nil, &blk) ⇒ Action
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initialize an action
70 71 72 73 74 75 |
# File 'lib/lotus/routing/resource/action.rb', line 70 def initialize(router, = {}, resource = nil, &blk) @router = router = @resource = resource generate(&blk) end |
Class Method Details
.generate(router, action, options = {}, resource = nil) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Generate an action for the given router
56 57 58 |
# File 'lib/lotus/routing/resource/action.rb', line 56 def self.generate(router, action, = {}, resource = nil) class_for(action).new(router, , resource) end |
Instance Method Details
#generate(&blk) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Generate an action for the given router
84 85 86 87 |
# File 'lib/lotus/routing/resource/action.rb', line 84 def generate(&blk) @router.send verb, path, to: endpoint, as: as instance_eval(&blk) if block_given? end |
#namespace ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Namespace
112 113 114 |
# File 'lib/lotus/routing/resource/action.rb', line 112 def namespace @namespace ||= Utils::PathPrefix.new [:namespace] end |
#resource_name ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Resource name
104 105 106 |
# File 'lib/lotus/routing/resource/action.rb', line 104 def resource_name @resource_name ||= [:name].to_s end |