Sha256: ef89396b6559a5bde89554daed7c7d7a69714e4515431890ff6a86eeddce228f
Contents?: true
Size: 993 Bytes
Versions: 2
Compression:
Stored size: 993 Bytes
Contents
module Support module Constants extend ActiveSupport::Concern module ClassMethods def uses_constants(*constants) before { create_constants *constants } after { remove_constants *constants } end end def create_constants(*constants) constants.each { |constant| create_constant constant } end def remove_constants(*constants) constants.each { |constant| remove_constant constant } end def create_constant(constant, superclass=nil) Object.const_set constant, Model(superclass) end def remove_constant(constant) if Object.const_defined?(constant) Object.send :remove_const, constant end end def Model(superclass=nil) if superclass.nil? Class.new { include Toy::Mongo adapter :mongo, STORE } else Class.new(superclass) { include Toy::Mongo adapter :mongo, STORE } end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
toystore-mongo-0.12.0 | spec/support/constants.rb |
toystore-mongo-0.11.0 | spec/support/constants.rb |