Class: MmJsonClient::TypeFactory
- Inherits:
-
Object
- Object
- MmJsonClient::TypeFactory
- Defined in:
- lib/mm_json_client/type_factory.rb
Overview
Dynamically create types and simplify their instantiation.
Class Attribute Summary collapse
-
.types ⇒ Object
readonly
Returns the value of attribute types.
Class Method Summary collapse
- .build_from_data(type_name, data = {}) ⇒ Object
-
.load_types(types = {}) ⇒ Object
Create type classes for the api definition.
Class Attribute Details
.types ⇒ Object (readonly)
Returns the value of attribute types.
20 21 22 |
# File 'lib/mm_json_client/type_factory.rb', line 20 def types @types end |
Class Method Details
.build_from_data(type_name, data = {}) ⇒ Object
13 14 15 16 17 |
# File 'lib/mm_json_client/type_factory.rb', line 13 def self.build_from_data(type_name, data = {}) return build_array_type(type_name, data) if data.class == Array return build_simple_type(type_name, data) if simple_type?(type_name) build_complex_type(type_name, data) end |
.load_types(types = {}) ⇒ Object
Create type classes for the api definition.
9 10 11 |
# File 'lib/mm_json_client/type_factory.rb', line 9 def self.load_types(types = {}) types.each { |type, definition| define(type, definition) } end |