Sha256: 8d3c620d9f3a91989c0f16e483b6912eacc536293104c439300c96b76bb15f16
Contents?: true
Size: 882 Bytes
Versions: 6
Compression:
Stored size: 882 Bytes
Contents
module Support module Objects extend ActiveSupport::Concern module ClassMethods def uses_objects(*objects) before { create_objects *objects } end end def create_objects(*objects) objects.each { |object| create_object object } end def remove_objects(*objects) objects.each { |object| remove_object object } end def create_object(object) remove_object object Object.const_set object, ToyObject(object) end def remove_object(object) if Object.const_defined?(object) Object.send :remove_const, object end end def ToyObject(name = nil) Class.new.tap do |object| object.class_eval """ def self.name; '#{name}' end def self.to_s; '#{name}' end """ if name object.send(:include, Toy::Object) end end end end
Version data entries
6 entries across 6 versions & 1 rubygems