Class: Struct
Constant Summary collapse
- STRUCT_TYPE =
:struct
Constants included from CommonStruct
CommonStruct::DEFAULT_STRUCT_TYPE
Instance Method Summary collapse
- #lock ⇒ Object
-
#merge(other) ⇒ Object
returns new object.
- #struct_type ⇒ Object
-
#unlock(type = ClassyStruct::STRUCT_TYPE) ⇒ Object
Convert Struct to OpenStruct or ClassyStruct (default), thus unlocking it.
Methods included from CommonStruct
Instance Method Details
#lock ⇒ Object
40 41 42 |
# File 'ext/struct.rb', line 40 def lock self #noop end |
#merge(other) ⇒ Object
returns new object
32 33 34 35 36 37 38 |
# File 'ext/struct.rb', line 32 def merge other selfHash = self.to_h otherHash = other.is_a?(Hash) ? other : other.to_h selfHash.merge!(otherHash) selfHash.to_struct(STRUCT_TYPE) end |
#struct_type ⇒ Object
7 8 9 |
# File 'ext/struct.rb', line 7 def struct_type STRUCT_TYPE end |
#unlock(type = ClassyStruct::STRUCT_TYPE) ⇒ Object
Convert Struct to OpenStruct or ClassyStruct (default), thus unlocking it.
45 46 47 48 |
# File 'ext/struct.rb', line 45 def unlock(type=ClassyStruct::STRUCT_TYPE) return nil if type.to_sym == Struct::STRUCT_TYPE return self.to_h.to_struct(type) end |