class Ebayr::Record

Public Class Methods

new(initial = {}) click to toggle source
Calls superclass method
# File lib/ebayr/record.rb, line 3
def initialize(initial = {})
  super()
  initial.each { |k, v| self[k] = v }
end

Protected Class Methods

convert_key(k) click to toggle source
# File lib/ebayr/record.rb, line 36
def self.convert_key(k)
  k.to_s.underscore.gsub(/e_bay/, "ebay").to_sym
end
convert_value(arg) click to toggle source
# File lib/ebayr/record.rb, line 44
def self.convert_value(arg)
  case arg
    when Hash then Record.new(arg)
    when Array then arg.map { |a| convert_value(a) }
    else arg
  end
end

Public Instance Methods

<=>(another) click to toggle source
# File lib/ebayr/record.rb, line 8
def <=>(another)
  return false unless another.respond_to(:keys) and another.respond_to(:"[]")
  another.keys.each do |k|
    return false unless convert_value(another[k]) == self[k]
  end
  true
end
[](key) click to toggle source
Calls superclass method
# File lib/ebayr/record.rb, line 16
def [](key)
  super(convert_key(key))
end
[]=(key, value) click to toggle source
Calls superclass method
# File lib/ebayr/record.rb, line 20
def []=(key, value)
  key = convert_key(key)
  value = convert_value(value)
  (class << self; self; end).send(:define_method, key) { value }
  super(key, value)
end
has_key?(key) click to toggle source
Calls superclass method
# File lib/ebayr/record.rb, line 27
def has_key?(key)
  super(convert_key(key))
end

Protected Instance Methods

convert_key(k) click to toggle source
# File lib/ebayr/record.rb, line 32
def convert_key(k)
  self.class.convert_key(k)
end
convert_value(arg) click to toggle source
# File lib/ebayr/record.rb, line 40
def convert_value(arg)
  self.class.convert_value(arg)
end