Sha256: ab19624ccb21be47757391e135c81cc216991f8b1bc2dc019079f2eb8049d2f1
Contents?: true
Size: 978 Bytes
Versions: 1
Compression:
Stored size: 978 Bytes
Contents
module Support module Constants def self.included(base) base.extend(ClassMethods) end module ClassMethods def uses_constants(*constants) before { create_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) remove_constant(constant) Kernel.const_set(constant, Model(constant)) end def remove_constant(constant) Kernel.send(:remove_const, constant) if Kernel.const_defined?(constant) end def Model(name=nil) Class.new.tap do |model| model.class_eval """ def self.name; '#{name}' end def self.to_s; '#{name}' end """ if name model.send(:include, Toy::Store) model.store(:couch, STORE) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
toystore-couch-0.1.0 | spec/support/constants.rb |