class SpikePay::Entity

Public Instance Methods

inspect()
Alias for: to_s
normalize_hash(hash) click to toggle source

Remove nil values and stringify keys

# File lib/spike_pay/data_types.rb, line 4
def normalize_hash(hash)
  hash.each_with_object({}) { |kv, obj| k,v = kv; obj[k.to_s] = v unless v == nil }
end
to_h() click to toggle source

Convert attributes and its children to pure-Ruby hash @return [Hash] pure ruby hash including no user objects

# File lib/spike_pay/data_types.rb, line 10
def to_h
  @attributes.each_with_object({}) do |kv, obj|
    k, v = kv
    next if v == nil
    obj[k] = v.is_a?(Entity) ? v.to_h : v
  end
end
Also aliased as: to_hash
to_hash()
Alias for: to_h
to_s() click to toggle source

Pretty print object's data

# File lib/spike_pay/data_types.rb, line 21
def to_s
  rendered = "#<#{self.class}\n"
  self.class.fields.each do |k|
    rendered << "  #{k}: " << @attributes[k].inspect.gsub(/(\r?\n)/, '\1  ') << "\n"
  end
  rendered << ">"
end
Also aliased as: inspect