Class: OpenStruct
Constant Summary collapse
- STRUCT_TYPE =
:open_struct
Constants included from CommonStruct
CommonStruct::DEFAULT_STRUCT_TYPE
Instance Method Summary collapse
-
#lock ⇒ Object
Convert OpenStruct to Struct, thus locking it.
-
#merge(other) ⇒ Object
returns new object.
-
#merge!(other) ⇒ Object
replaces object.
- #struct_type ⇒ Object
- #unlock ⇒ Object
Methods included from CommonStruct
Instance Method Details
#lock ⇒ Object
Convert OpenStruct to Struct, thus locking it.
42 43 44 |
# File 'ext/openstruct.rb', line 42 def lock self.to_h.to_struct(Struct::STRUCT_TYPE) end |
#merge(other) ⇒ Object
returns new object
37 38 39 |
# File 'ext/openstruct.rb', line 37 def merge other OpenStruct.new(self.to_h.merge(other.to_h)) end |
#merge!(other) ⇒ Object
replaces object
32 33 34 |
# File 'ext/openstruct.rb', line 32 def merge! other self.marshal_load(merge(other).to_h) end |
#struct_type ⇒ Object
27 28 29 |
# File 'ext/openstruct.rb', line 27 def struct_type STRUCT_TYPE end |
#unlock ⇒ Object
46 47 48 |
# File 'ext/openstruct.rb', line 46 def unlock self # noop end |