Class: Belt::Route
- Inherits:
-
Object
- Object
- Belt::Route
- Defined in:
- lib/belt/route_dsl.rb
Overview
DSL for defining API Gateway routes. Ported from terraform-provider-conveyor-belt/scripts/lib/route_dsl.rb so that ‘belt routes` can parse routes.tf.rb without external dependencies.
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#auth ⇒ Object
readonly
Returns the value of attribute auth.
-
#controller ⇒ Object
readonly
Returns the value of attribute controller.
-
#cors ⇒ Object
readonly
Returns the value of attribute cors.
-
#lambda ⇒ Object
readonly
Returns the value of attribute lambda.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#request_model ⇒ Object
readonly
Returns the value of attribute request_model.
-
#response_context ⇒ Object
readonly
Returns the value of attribute response_context.
-
#response_model ⇒ Object
readonly
Returns the value of attribute response_model.
-
#route_type ⇒ Object
readonly
Returns the value of attribute route_type.
-
#tables ⇒ Object
readonly
Returns the value of attribute tables.
Instance Method Summary collapse
- #action? ⇒ Boolean
-
#initialize(method, path, options = {}) ⇒ Route
constructor
A new instance of Route.
- #plural_resource? ⇒ Boolean
- #resource? ⇒ Boolean
- #singular_resource? ⇒ Boolean
Constructor Details
#initialize(method, path, options = {}) ⇒ Route
Returns a new instance of Route.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/belt/route_dsl.rb', line 12 def initialize(method, path, = {}) @method = method.to_s.upcase @path = normalize_path(path) @auth = [:auth] @lambda = [:lambda] @cors = .fetch(:cors, true) @tables = [:tables] || [] @route_type = [:route_type] || :action @controller = [:controller] @action = [:action] @request_model = [:request_model]&.to_s @response_model = [:response_model]&.to_s @response_context = [:response_context]&.to_s end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
9 10 11 |
# File 'lib/belt/route_dsl.rb', line 9 def action @action end |
#auth ⇒ Object (readonly)
Returns the value of attribute auth.
9 10 11 |
# File 'lib/belt/route_dsl.rb', line 9 def auth @auth end |
#controller ⇒ Object (readonly)
Returns the value of attribute controller.
9 10 11 |
# File 'lib/belt/route_dsl.rb', line 9 def controller @controller end |
#cors ⇒ Object (readonly)
Returns the value of attribute cors.
9 10 11 |
# File 'lib/belt/route_dsl.rb', line 9 def cors @cors end |
#lambda ⇒ Object (readonly)
Returns the value of attribute lambda.
9 10 11 |
# File 'lib/belt/route_dsl.rb', line 9 def lambda @lambda end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
9 10 11 |
# File 'lib/belt/route_dsl.rb', line 9 def method @method end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
9 10 11 |
# File 'lib/belt/route_dsl.rb', line 9 def path @path end |
#request_model ⇒ Object (readonly)
Returns the value of attribute request_model.
9 10 11 |
# File 'lib/belt/route_dsl.rb', line 9 def request_model @request_model end |
#response_context ⇒ Object (readonly)
Returns the value of attribute response_context.
9 10 11 |
# File 'lib/belt/route_dsl.rb', line 9 def response_context @response_context end |
#response_model ⇒ Object (readonly)
Returns the value of attribute response_model.
9 10 11 |
# File 'lib/belt/route_dsl.rb', line 9 def response_model @response_model end |
#route_type ⇒ Object (readonly)
Returns the value of attribute route_type.
9 10 11 |
# File 'lib/belt/route_dsl.rb', line 9 def route_type @route_type end |
#tables ⇒ Object (readonly)
Returns the value of attribute tables.
9 10 11 |
# File 'lib/belt/route_dsl.rb', line 9 def tables @tables end |
Instance Method Details
#action? ⇒ Boolean
39 40 41 |
# File 'lib/belt/route_dsl.rb', line 39 def action? @route_type == :action end |
#plural_resource? ⇒ Boolean
35 36 37 |
# File 'lib/belt/route_dsl.rb', line 35 def plural_resource? @route_type == :resources end |
#resource? ⇒ Boolean
27 28 29 |
# File 'lib/belt/route_dsl.rb', line 27 def resource? @route_type == :resource || @route_type == :resources end |
#singular_resource? ⇒ Boolean
31 32 33 |
# File 'lib/belt/route_dsl.rb', line 31 def singular_resource? @route_type == :resource end |