Module: HashToStruct
- Defined in:
- lib/hash_to_struct.rb,
lib/hash_to_struct/struct.rb,
lib/hash_to_struct/version.rb,
lib/hash_to_struct/struct_builder.rb,
lib/hash_to_struct/open_struct_builder.rb
Defined Under Namespace
Classes: OpenStructBuilder, Struct, StructBuilder
Constant Summary
collapse
- VERSION =
"1.0.0"
Class Method Summary
collapse
Class Method Details
.build(h, **opts) ⇒ Object
7
8
9
|
# File 'lib/hash_to_struct.rb', line 7
def build(h, **opts)
HashToStruct::Struct.new(h, **opts)
end
|
.ostruct(hash, **opts) ⇒ Object
15
16
17
18
|
# File 'lib/hash_to_struct.rb', line 15
def ostruct(hash, **opts)
require 'hash_to_struct/open_struct_builder'
build(hash, **opts.merge({builder_class: HashToStruct::OpenStructBuilder}))
end
|
.struct(hash, **opts) ⇒ Object
11
12
13
|
# File 'lib/hash_to_struct.rb', line 11
def struct(hash, **opts)
build(hash, **opts.merge({builder_class: HashToStruct::StructBuilder}))
end
|