Class: HashToStruct::Struct

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/hash_to_struct/struct.rb

Instance Method Summary collapse

Constructor Details

#initialize(hash, builder_class: HashToStruct::StructBuilder, immutable: false, including_arrays: false) ⇒ Struct

Returns a new instance of Struct.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/hash_to_struct/struct.rb', line 5

def initialize(
      hash,
      builder_class: HashToStruct::StructBuilder,
      immutable: false,
      including_arrays: false
    )
  @options = {
    builder_class: builder_class,
    immutable: immutable,
    including_arrays: including_arrays
  }
  __setobj__(to_struct(hash))
  freeze if immutable
end

Instance Method Details

#to_hObject



20
21
22
# File 'lib/hash_to_struct/struct.rb', line 20

def to_h
  to_hash
end