Module: SolidStruct
- Defined in:
- lib/solid_struct.rb
Overview
Allow structs to be initialised using a hash
Defined Under Namespace
Classes: NamedStruct
Constant Summary collapse
- VERSION =
"0.1.0"
Class Method Summary collapse
Class Method Details
.build(hash) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/solid_struct.rb', line 20 def self.build(hash) raise ArgumentError.new("Arguments must be defined as a hash") unless hash.is_a? Hash klass = NamedStruct.new(*hash.keys) klass.new(hash) end |
.new(*args) ⇒ Object
16 17 18 |
# File 'lib/solid_struct.rb', line 16 def self.new(*args) NamedStruct.new(*args) end |