Class: AdequateJson::Hash

Inherits:
Object
  • Object
show all
Includes:
Jsonizer, Resolver
Defined in:
lib/adequate_json/hash.rb

Instance Method Summary collapse

Methods included from Jsonizer

#to_json

Methods included from Resolver

#choose_serializer

Constructor Details

#initialize(hash, json = nil, variants: {}) ⇒ Hash

Returns a new instance of Hash.



8
9
10
11
12
# File 'lib/adequate_json/hash.rb', line 8

def initialize(hash, json = nil, variants: {}, **)
  @hash = hash
  @json = json
  @variants = variants
end

Instance Method Details

#to_builderObject



14
15
16
17
18
19
20
21
22
23
# File 'lib/adequate_json/hash.rb', line 14

def to_builder
  if @json.nil?
    Jbuilder.new do |json|
      @json = json
      serialize_hash
    end
  else
    serialize_hash
  end
end