Module: StructureMapper::Hash
- Defined in:
- lib/structure_mapper.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
95 96 97 |
# File 'lib/structure_mapper.rb', line 95 def self.included(base) base.extend ClassMethods end |
Instance Method Details
#==(other) ⇒ Object
107 108 109 110 111 112 113 |
# File 'lib/structure_mapper.rb', line 107 def == other return false unless self.class == other.class self.class.attributes.each do |name,_| return false unless self.send(name) == other.send(name) end true end |
#to_structure ⇒ Object
99 100 101 102 103 104 105 |
# File 'lib/structure_mapper.rb', line 99 def to_structure ::Hash[ (self.class.attributes || {}).map do |name,type| [name.to_s,public_send(name).to_structure] end ] end |