Class: Chaplin::Parser::ApiEndpoints

Inherits:
Object
  • Object
show all
Defined in:
lib/chaplin/parser/api_endpoints.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_endpoint_declaration) ⇒ ApiEndpoints

Returns a new instance of ApiEndpoints.



18
19
20
# File 'lib/chaplin/parser/api_endpoints.rb', line 18

def initialize(api_endpoint_declaration)
  @api_endpoint_declaration = [api_endpoint_declaration].flatten
end

Class Method Details

.build(api_endpoint_declaration) ⇒ Object



14
15
16
# File 'lib/chaplin/parser/api_endpoints.rb', line 14

def self.build(api_endpoint_declaration)
  new(api_endpoint_declaration).build
end

.valid?(raw_data_value) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
12
# File 'lib/chaplin/parser/api_endpoints.rb', line 9

def self.valid?(raw_data_value)
  http_verbs = ['get ', 'post ', 'put ', 'head ', 'delete ']
  [raw_data_value].flatten.first.downcase.start_with?(*http_verbs)
end

Instance Method Details

#buildObject



22
23
24
# File 'lib/chaplin/parser/api_endpoints.rb', line 22

def build
  ApiEndpoint.new(http_method, path, params, headers)
end