Class: Fixjour::Attributes

Inherits:
Hash
  • Object
show all
Defined in:
lib/fixjour/attributes.rb

Instance Method Summary collapse

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

Returns:

  • (Boolean)


17
18
19
# File 'lib/fixjour/attributes.rb', line 17

def has_key?(key)
  super key.to_s
end