Class: OpenStruct
- Inherits:
-
Object
- Object
- OpenStruct
- Defined in:
- lib/firm/serializer/json.rb
Class Method Summary collapse
-
.json_create(object) ⇒ OpenStruct
Create a new OpenStruct instance from deserialized JSON data.
Instance Method Summary collapse
Methods included from FIRM::Serializable::CoreExt
Methods included from FIRM::Serializable::JSON::ContainerPatch
Class Method Details
.json_create(object) ⇒ OpenStruct
Create a new OpenStruct instance from deserialized JSON data.
430 431 432 |
# File 'lib/firm/serializer/json.rb', line 430 def json_create(object) json_new(object) { |instance| object['t'].each { |k,v| instance[k] = v } } end |
Instance Method Details
#as_json ⇒ Object
435 436 437 438 439 |
# File 'lib/firm/serializer/json.rb', line 435 def as_json(*) build_json do |json_data| json_data['t'] = table.collect { |k,v| [k.respond_to?(:as_json) ? k.as_json : k, v.respond_to?(:as_json) ? v.as_json : v] } end end |