Class: Array

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) ⇒ Array

Create a new Array instance from deserialized JSON data.

Parameters:

  • object (Hash)

    deserialized JSON object

Returns:

  • (Array)

    restored Array instance



349
350
351
# File 'lib/firm/serializer/json.rb', line 349

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

Instance Method Details

#as_jsonObject



354
355
356
357
358
# File 'lib/firm/serializer/json.rb', line 354

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