Class: Flame::Router::RoutesRefine
- Inherits:
-
Object
- Object
- Flame::Router::RoutesRefine
- Extended by:
- Memery
- Includes:
- Mounting
- Defined in:
- lib/flame/router/routes_refine.rb,
lib/flame/router/routes_refine/mounting.rb
Overview
Helper class for controller routing refine
Defined Under Namespace
Modules: Mounting
Instance Attribute Summary collapse
-
#reverse_routes ⇒ Object
readonly
Returns the value of attribute reverse_routes.
-
#routes ⇒ Object
readonly
Returns the value of attribute routes.
Class Method Summary collapse
-
.rest_routes ⇒ Object
Defaults REST routes (methods, pathes, controllers actions).
Instance Method Summary collapse
-
#initialize(namespace_name, controller_or_name, path, nested: true) ⇒ RoutesRefine
constructor
A new instance of RoutesRefine.
Constructor Details
#initialize(namespace_name, controller_or_name, path, nested: true) ⇒ RoutesRefine
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/flame/router/routes_refine.rb', line 28 def initialize(namespace_name, controller_or_name, path, nested: true, &) @controller = ControllerFinder.new(namespace_name, controller_or_name).controller @namespace_name = @controller.deconstantize @path = Flame::Path.new(path || @controller.path) @controller.path_arguments = @path.parts.select(&:arg?).map(&:to_sym) @routes, @endpoint = @path.to_routes_with_endpoint @reverse_routes = {} @mount_nested = nested execute(&) end |
Instance Attribute Details
#reverse_routes ⇒ Object (readonly)
Returns the value of attribute reverse_routes.
9 10 11 |
# File 'lib/flame/router/routes_refine.rb', line 9 def reverse_routes @reverse_routes end |
#routes ⇒ Object (readonly)
Returns the value of attribute routes.
9 10 11 |
# File 'lib/flame/router/routes_refine.rb', line 9 def routes @routes end |
Class Method Details
.rest_routes ⇒ Object
Defaults REST routes (methods, pathes, controllers actions)
15 16 17 18 19 20 21 22 23 |
# File 'lib/flame/router/routes_refine.rb', line 15 def rest_routes [ { method: :GET, path: '/', action: :index }, { method: :POST, path: '/', action: :create }, { method: :GET, path: '/', action: :show }, { method: :PUT, path: '/', action: :update }, { method: :DELETE, path: '/', action: :delete } ] end |