Class: Taro::Route
- Inherits:
-
Object
- Object
- Taro::Route
- Defined in:
- lib/taro/route.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#endpoint ⇒ Object
readonly
Returns the value of attribute endpoint.
-
#openapi_operation_id ⇒ Object
readonly
Returns the value of attribute openapi_operation_id.
-
#openapi_path ⇒ Object
readonly
Returns the value of attribute openapi_path.
-
#verb ⇒ Object
readonly
Returns the value of attribute verb.
Instance Method Summary collapse
- #can_have_request_body? ⇒ Boolean
-
#initialize(endpoint:, openapi_operation_id:, openapi_path:, verb:) ⇒ Route
constructor
A new instance of Route.
- #inspect ⇒ Object (also: #to_s)
- #path_params ⇒ Object
Constructor Details
#initialize(endpoint:, openapi_operation_id:, openapi_path:, verb:) ⇒ Route
Returns a new instance of Route.
4 5 6 7 8 9 |
# File 'lib/taro/route.rb', line 4 def initialize(endpoint:, openapi_operation_id:, openapi_path:, verb:) @endpoint = validate_string(endpoint:) @openapi_operation_id = validate_string(openapi_operation_id:) @openapi_path = validate_string(openapi_path:) @verb = validate_string(verb:).downcase end |
Instance Attribute Details
#endpoint ⇒ Object (readonly)
Returns the value of attribute endpoint.
2 3 4 |
# File 'lib/taro/route.rb', line 2 def endpoint @endpoint end |
#openapi_operation_id ⇒ Object (readonly)
Returns the value of attribute openapi_operation_id.
2 3 4 |
# File 'lib/taro/route.rb', line 2 def openapi_operation_id @openapi_operation_id end |
#openapi_path ⇒ Object (readonly)
Returns the value of attribute openapi_path.
2 3 4 |
# File 'lib/taro/route.rb', line 2 def openapi_path @openapi_path end |
#verb ⇒ Object (readonly)
Returns the value of attribute verb.
2 3 4 |
# File 'lib/taro/route.rb', line 2 def verb @verb end |
Instance Method Details
#can_have_request_body? ⇒ Boolean
15 16 17 |
# File 'lib/taro/route.rb', line 15 def can_have_request_body? %w[patch post put].include?(verb) end |
#inspect ⇒ Object Also known as: to_s
19 20 21 |
# File 'lib/taro/route.rb', line 19 def inspect %(#<#{self.class} "#{verb} #{openapi_path}">) end |
#path_params ⇒ Object
11 12 13 |
# File 'lib/taro/route.rb', line 11 def path_params openapi_path.scan(/{(\w+)}/).flatten.map(&:to_sym) end |