Class: OpenStruct

Inherits:
Object
  • Object
show all
Includes:
FIRM::Serializable::CoreExt, FIRM::Serializable::JSON::ContainerPatch
Defined in:
lib/firm/serializer/json.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from FIRM::Serializable::CoreExt

included, #serialize

Methods included from FIRM::Serializable::JSON::ContainerPatch

included

Class Method Details

.json_create(object) ⇒ OpenStruct

Create a new OpenStruct instance from deserialized JSON data.

Parameters:

  • object (Hash)

    deserialized JSON object

Returns:



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_jsonObject



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