Class: OpenStruct

Inherits:
Object
  • Object
show all
Includes:
CommonStruct
Defined in:
ext/openstruct.rb

Constant Summary collapse

STRUCT_TYPE =
:open_struct

Constants included from CommonStruct

CommonStruct::DEFAULT_STRUCT_TYPE

Instance Method Summary collapse

Methods included from CommonStruct

#delete, #to_json, #to_struct

Instance Method Details

#lockObject

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_typeObject



27
28
29
# File 'ext/openstruct.rb', line 27

def struct_type
  STRUCT_TYPE
end

#unlockObject



46
47
48
# File 'ext/openstruct.rb', line 46

def unlock
  self # noop
end