Class: Apiture::APIBuilder
- Inherits:
-
Object
- Object
- Apiture::APIBuilder
- Includes:
- Utils::Inflections
- Defined in:
- lib/apiture/api_builder.rb
Constant Summary collapse
- ACCEPT =
'Accept'.freeze
- CONTENT_TYPE =
'Content-Type'.freeze
- CONTENT_TYPE_FORM_URLENCODED =
'application/x-www-form-urlencoded'.freeze
- USER_AGENT =
'User-Agent'.freeze
Instance Attribute Summary collapse
-
#specification ⇒ Object
readonly
Returns the value of attribute specification.
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(specification) ⇒ APIBuilder
constructor
A new instance of APIBuilder.
Methods included from Utils::Inflections
acronym_regex, acronyms, #camelize, #constantize, #underscore
Constructor Details
#initialize(specification) ⇒ APIBuilder
Returns a new instance of APIBuilder.
23 24 25 |
# File 'lib/apiture/api_builder.rb', line 23 def initialize(specification) @specification = specification end |
Instance Attribute Details
#specification ⇒ Object (readonly)
Returns the value of attribute specification.
21 22 23 |
# File 'lib/apiture/api_builder.rb', line 21 def specification @specification end |
Instance Method Details
#build ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/apiture/api_builder.rb', line 27 def build validate! create_api_class.tap do |klass| klass.api_groups = [ APIGroup.new.tap do |group| group.endpoints = build_endpoints group.endpoints.each do |endpoint| klass.send(:define_method, endpoint.name.to_sym) do |*args| group.execute(self., endpoint, *args) end end end ] #Apiture.const_set create_class_name(name), klass end end |