Sha256: 8153937641d694866d3d4db867db526aa0d79a29962e70980b81345568076705
Contents?: true
Size: 1.3 KB
Versions: 10
Compression:
Stored size: 1.3 KB
Contents
class BtrieveModel include Btrieve def initialize(classname, tablename) session = BtrieveSession.get_session() table = BtrieveTable.new(tablename, session) session.model_classes[classname] = table end def self.new_record() BtrieveRecord.new(get_table()) end def self.find_in_unique_index(match, index_number) get_table().find_in_unique_index(match, index_number) end def self.find_in_index(match, index_number) get_table().find_in_index(match, index_number) end def self.each_record(mode=ACCELERATED_MODE, &block) get_table().each_record(mode, &block) end def self.batch(mode=ACCELERATED_MODE, &block) get_table().batch(mode, &block) end def self.one_to_one(association) get_table().schema[:one_to_one][association[:name]]=association end def self.one_to_many(association) get_table().schema[:one_to_many][association[:name]]=association end private def self.get_table() session = BtrieveSession.get_session() session.model_classes[self.name.to_sym] end end def BtrieveModel(classname, tablename) raise Exception.new("The context is not set. Call 'Btrieve::Session.set_context( <pathname> )' before declaring model classes.") unless BtrieveSession.get_session() != nil BtrieveModel.new(classname, tablename) BtrieveModel end
Version data entries
10 entries across 10 versions & 1 rubygems