Class: Set

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

Class Method Summary collapse

Instance Method Summary collapse

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

included

Class Method Details

.json_create(object) ⇒ Set

Create a new Set instance from deserialized JSON data.

Parameters:

  • object (Hash)

    deserialized JSON object

Returns:

  • (Set)

    restored Set instance



387
388
389
# File 'lib/firm/serializer/json.rb', line 387

def json_create(object)
  json_new(object) { |instance| instance.replace(object['a']) }
end

Instance Method Details

#as_jsonObject



392
393
394
395
396
# File 'lib/firm/serializer/json.rb', line 392

def as_json(*)
  build_json do |json_data|
    json_data['a'] = to_a.collect { |e| e.respond_to?(:as_json) ? e.as_json : e }
  end
end