Sha256: 9138f08a6c074fea7a1587c75bbaf8d021397e74eeda840b0790cea7e3fdea8a
Contents?: true
Size: 676 Bytes
Versions: 1
Compression:
Stored size: 676 Bytes
Contents
module LightspeedRestaurant 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) value = ['Missing', 'N/A', ''].include?(value) ? nil : value instance_variable_set("@#{key}", value) convert_to_obj(value) if value.is_a? Hash end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
lightspeed_restaurant-0.1.4 | lib/lightspeed_restaurant/base.rb |