Class: Taro::Route

Inherits:
Object
  • Object
show all
Defined in:
lib/taro/route.rb

Direct Known Subclasses

Taro::Rails::NormalizedRoute

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#endpointObject (readonly)

Returns the value of attribute endpoint.



2
3
4
# File 'lib/taro/route.rb', line 2

def endpoint
  @endpoint
end

#openapi_operation_idObject (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_pathObject (readonly)

Returns the value of attribute openapi_path.



2
3
4
# File 'lib/taro/route.rb', line 2

def openapi_path
  @openapi_path
end

#verbObject (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

Returns:

  • (Boolean)


15
16
17
# File 'lib/taro/route.rb', line 15

def can_have_request_body?
  %w[patch post put].include?(verb)
end

#inspectObject Also known as: to_s



19
20
21
# File 'lib/taro/route.rb', line 19

def inspect
  %(#<#{self.class} "#{verb} #{openapi_path}">)
end

#path_paramsObject



11
12
13
# File 'lib/taro/route.rb', line 11

def path_params
  openapi_path.scan(/{(\w+)}/).flatten.map(&:to_sym)
end