Sha256: 16c7d0a37ffa1b3fb9ba53f76b8194e3750aea25bc089a0d81af58873620d22e
Contents?: true
Size: 689 Bytes
Versions: 12
Compression:
Stored size: 689 Bytes
Contents
require 'ostruct' module Clearsale class Object < OpenStruct def new_ostruct_member(name) name = name.to_sym unless self.respond_to?(name) class << self; self; end.class_eval do define_method(name) { v = @table[name] case v when Hash Object.new(v) when Array v.each_with_index { |item, index| v[index] = Object.new(item) } else v end } define_method("#{name}=") { |x| modifiable[name] = x } define_method("#{name}_as_a_hash") { @table[name] } end end name end end end
Version data entries
12 entries across 12 versions & 2 rubygems