Sha256: 3d8546171c3a51dfb3a91e323183ac341bd3cac0bad65b93877439584cd2930f
Contents?: true
Size: 613 Bytes
Versions: 4
Compression:
Stored size: 613 Bytes
Contents
module LightspeedRestaurantClient class Base def initialize(data = {}) convert_to_obj(data) end 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 def to_json attributes.to_json end private def convert_to_obj(h) h.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 end end
Version data entries
4 entries across 4 versions & 1 rubygems