Class: OneApi::Conversions
- Inherits:
-
Object
- Object
- OneApi::Conversions
- Defined in:
- lib/oneapi-ruby/objects.rb
Class Method Summary collapse
- .fill_from_json(object, json, is_error = nil) ⇒ Object
- .from_json(classs, json, is_error = nil) ⇒ Object
- .to_json ⇒ Object
Class Method Details
.fill_from_json(object, json, is_error = nil) ⇒ Object
134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/oneapi-ruby/objects.rb', line 134 def self.fill_from_json(object, json, is_error=nil) if is_error object.exception = Conversions.from_json(OneApiError, json, false) return end json = JSONUtils.get_json(json) conversion_rules = OneApiAccessorModifier.get_field_conversion_rules(object.class) for conversion_rule in conversion_rules json_value = JSONUtils.get(json, conversion_rule.json_field_name) value = conversion_rule.from_json(json_value) object.instance_variable_set("@#{conversion_rule.object_field_name}", value) end end |
.from_json(classs, json, is_error = nil) ⇒ Object
126 127 128 129 130 131 132 |
# File 'lib/oneapi-ruby/objects.rb', line 126 def self.from_json(classs, json, is_error=nil) object = classs.new Conversions.fill_from_json(object, json, is_error) object end |
.to_json ⇒ Object
149 150 151 |
# File 'lib/oneapi-ruby/objects.rb', line 149 def self.to_json # TODO(TK) end |