Sha256: 65f8e64ef841b18349ba3ae61a7501e17f8f415bcbf6b70cfcc4c67f1874a619
Contents?: true
Size: 1.36 KB
Versions: 6
Compression:
Stored size: 1.36 KB
Contents
module Swift class Scheme attr_accessor :tuple alias_method :scheme, :class def initialize options = {} @tuple = scheme.header.new_tuple options.each{|k, v| send(:"#{k}=", v)} end def update options = {} options.each{|k, v| send(:"#{k}=", v)} Swift.db.update(scheme, self) end def destroy Swift.db.destroy(scheme, self) end class << self attr_accessor :header def inherited klass klass.header = Header.new klass.header.push(*header) if header Swift.schema.push(klass) if klass.name end def load tuple scheme = allocate scheme.tuple = tuple scheme end def attribute name, type, options = {} header.push(attribute = type.new(self, name, options)) (class << self; self end).send(:define_method, name, lambda{ attribute }) end def store name = nil name ? @store = name : @store end def create options = {} Swift.db.create(self, options) end def get keys Swift.db.get(self, keys) end def all conditions = '', *binds, &block Swift.db.all(self, conditions, *binds, &block) end def first conditions = '', *binds, &block Swift.db.first(self, conditions, *binds, &block) end end end # Scheme end # Swift
Version data entries
6 entries across 6 versions & 1 rubygems