class PlaidObject
Public Class Methods
new(hash)
click to toggle source
# File lib/plaid/plaid_object.rb, line 3 def initialize(hash) hash.keys.each do |key| self.class.send(:define_method, "#{key}") do instance_variable_get("@#{key}") end if hash[key].is_a? Array arr = [] hash[key].each do |chunk| if chunk.is_a? Hash arr << PlaidObject.new(chunk) else arr << chunk end end instance_variable_set("@#{key}", arr) elsif hash[key].is_a? Hash h = hash[key] instance_variable_set("@#{key}", h) else eval("@#{key} = '#{encode(hash[key].to_s)}'") end end end
Public Instance Methods
encode(str)
click to toggle source
# File lib/plaid/plaid_object.rb, line 29 def encode(str) str.gsub("'", "") end