class LightspeedRestaurantClient::Base
Public Class Methods
new(data = {})
click to toggle source
# File lib/lightspeed_restaurant/base.rb, line 5 def initialize(data = {}) convert_to_obj(data) end
Public Instance Methods
attributes()
click to toggle source
# File lib/lightspeed_restaurant/base.rb, line 9 def attributes instance_variables.each_with_object({}) do |instance_variable, h| h[instance_variable[1..instance_variable.length]] = instance_variable_get(instance_variable) end end
to_json()
click to toggle source
# File lib/lightspeed_restaurant/base.rb, line 15 def to_json attributes.to_json end
Private Instance Methods
convert_to_obj(hash)
click to toggle source
# File lib/lightspeed_restaurant/base.rb, line 21 def convert_to_obj(hash) hash.each do |key, value| self.class.send(:attr_accessor, key) instance_variable_set("@#{key}", value) convert_to_obj(value) if value.is_a? Hash end end