Class: Value
Overview
Copyright Stefan Dorn <[email protected]>, 2016 License: GNU GPLv3 (or later) <www.gnu.org/copyleft/gpl.html>
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
- #inspect ⇒ Object
- #recursive_to_h ⇒ Object
- #to_a ⇒ Object
- #to_h ⇒ Object
Class Method Details
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
7 8 9 |
# File 'lib/muflax/value.rb', line 7 def ==(other) self.class == other.class && differences_with(other).empty? end |
#hash ⇒ Object
16 17 18 |
# File 'lib/muflax/value.rb', line 16 def hash to_a.hash end |
#inspect ⇒ Object
12 13 14 |
# File 'lib/muflax/value.rb', line 12 def inspect "#<#{self.class.name} #{to_h}>" end |
#recursive_to_h ⇒ Object
24 25 26 |
# File 'lib/muflax/value.rb', line 24 def recursive_to_h Hash[to_a.map{|k, v| [k, Value.coerce_to_h(v)]}] end |
#to_a ⇒ Object
28 29 30 |
# File 'lib/muflax/value.rb', line 28 def to_a self.class.attributes.map {|attr| [attr, send(attr)] } end |
#to_h ⇒ Object
20 21 22 |
# File 'lib/muflax/value.rb', line 20 def to_h Hash[to_a] end |