Sha256: e48900dddfd8b6085fcef4b53a90af4b9ac5a575a5513ed63c84b67d90b871bb
Contents?: true
Size: 395 Bytes
Versions: 7
Compression:
Stored size: 395 Bytes
Contents
def class_factory(opts = {}, &block) Class.new(described_class).tap do |klass| klass.class_eval(&block) if block_given? Object.const_set(opts[:real_class_name], klass) if opts[:real_class_name] klass.class_eval("def self.name; \"#{name}\"; end") if opts[:name] end end def object_factory(opts = {}, &block) class_factory(opts, &block).new(opts.fetch(:attributes, {})) end
Version data entries
7 entries across 7 versions & 1 rubygems