Class: Apiture::APIBuilder
- Inherits:
-
Object
- Object
- Apiture::APIBuilder
- Includes:
- Utils::Inflections
- Defined in:
- lib/apiture/api_builder.rb
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.
18 19 20 |
# File 'lib/apiture/api_builder.rb', line 18 def initialize(specification) @specification = specification end |
Instance Attribute Details
#specification ⇒ Object (readonly)
Returns the value of attribute specification.
16 17 18 |
# File 'lib/apiture/api_builder.rb', line 16 def specification @specification end |
Instance Method Details
#build ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/apiture/api_builder.rb', line 22 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 |