Class: Jsonism::Definer
- Inherits:
-
Object
- Object
- Jsonism::Definer
- Defined in:
- lib/jsonism/definer.rb
Class Method Summary collapse
-
.call(*args) ⇒ Object
Utility wrapper.
-
.extract_links(schema) ⇒ Array<JsonSchema::Schema::Link>
Recursively extracts all links from given JSON schema.
Instance Method Summary collapse
-
#call ⇒ Object
Defines methods to call HTTP request from its JSON schema.
-
#initialize(client: nil, schema: nil) ⇒ Definer
constructor
A new instance of Definer.
Constructor Details
#initialize(client: nil, schema: nil) ⇒ Definer
Returns a new instance of Definer.
18 19 20 21 |
# File 'lib/jsonism/definer.rb', line 18 def initialize(client: nil, schema: nil) @client = client @schema = schema end |
Class Method Details
.call(*args) ⇒ Object
Utility wrapper
4 5 6 |
# File 'lib/jsonism/definer.rb', line 4 def self.call(*args) new(*args).call end |
.extract_links(schema) ⇒ Array<JsonSchema::Schema::Link>
Recursively extracts all links from given JSON schema
11 12 13 14 |
# File 'lib/jsonism/definer.rb', line 11 def self.extract_links(schema) links = schema.links.select {|link| link.method && link.href } links + schema.properties.map {|key, schema| extract_links(schema) }.flatten end |
Instance Method Details
#call ⇒ Object
Defines methods to call HTTP request from its JSON schema
24 25 26 27 |
# File 'lib/jsonism/definer.rb', line 24 def call define_methods_into(@client) define_classes end |