Class: Dryer::Routes::Route
- Inherits:
-
Object
- Object
- Dryer::Routes::Route
- Defined in:
- lib/dryer/routes/route.rb
Instance Method Summary collapse
- #controller ⇒ Object
-
#initialize(route_config) ⇒ Route
constructor
A new instance of Route.
- #method ⇒ Object
- #request_contract ⇒ Object
- #response_contract_for(status) ⇒ Object
- #to_rails_route(router) ⇒ Object
- #url(*args) ⇒ Object
- #url_parameters_contract ⇒ Object
Constructor Details
#initialize(route_config) ⇒ Route
Returns a new instance of Route.
4 5 6 |
# File 'lib/dryer/routes/route.rb', line 4 def initialize(route_config) @route_config = route_config end |
Instance Method Details
#controller ⇒ Object
20 21 22 |
# File 'lib/dryer/routes/route.rb', line 20 def controller route_config[:controller] end |
#method ⇒ Object
24 25 26 |
# File 'lib/dryer/routes/route.rb', line 24 def method route_config[:method] end |
#request_contract ⇒ Object
28 29 30 |
# File 'lib/dryer/routes/route.rb', line 28 def request_contract route_config[:request_contract] end |
#response_contract_for(status) ⇒ Object
36 37 38 |
# File 'lib/dryer/routes/route.rb', line 36 def response_contract_for(status) route_config[:response_contracts][status] end |
#to_rails_route(router) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/dryer/routes/route.rb', line 8 def to_rails_route(router) router.send( route_config[:method], route_config[:url], to: "#{ route_config[:controller].controller_path }##{ route_config[:controller_action] }" ) end |
#url(*args) ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/dryer/routes/route.rb', line 40 def url(*args) if route_config[:url].is_a?(Proc) route_config[:url].call(*args) else route_config[:url] end end |
#url_parameters_contract ⇒ Object
32 33 34 |
# File 'lib/dryer/routes/route.rb', line 32 def url_parameters_contract route_config[:url_parameters_contract] end |