Class: Fixjour::Attributes
Instance Method Summary collapse
- #==(other) ⇒ Object
- #[](key) ⇒ Object
- #has_key?(key) ⇒ Boolean
-
#initialize(hash) ⇒ Attributes
constructor
A new instance of Attributes.
Constructor Details
#initialize(hash) ⇒ Attributes
Returns a new instance of Attributes.
3 4 5 6 7 8 9 10 11 |
# File 'lib/fixjour/attributes.rb', line 3 def initialize(hash) hash.each do |k, v| self[k.to_s] = v unless v.nil? end each do |k, v| (class << self; self; end).send(:define_method, k) { v } end end |
Instance Method Details
#==(other) ⇒ Object
21 22 23 |
# File 'lib/fixjour/attributes.rb', line 21 def ==(other) other.all? {|k, v| self[k] == v } end |
#[](key) ⇒ Object
13 14 15 |
# File 'lib/fixjour/attributes.rb', line 13 def [](key) super key.to_s end |
#has_key?(key) ⇒ Boolean
17 18 19 |
# File 'lib/fixjour/attributes.rb', line 17 def has_key?(key) super key.to_s end |