Class: RStore::BaseDB
- Inherits:
-
Object
- Object
- RStore::BaseDB
- Defined in:
- lib/rstore/base_db.rb
Class Attribute Summary (collapse)
-
+ (Hash{Symbol=>BaseDB}) db_classes
readonly
A Hash holding subclasses of BaseDB.
Class Method Summary (collapse)
-
+ connect {|db| ... }
Uses the connection info from BaseDB.info to connect to the database.
-
+ info(options)
Define the database connection.
-
+ (Symbol) name
The lower-case class name without the DB postfix.
Class Attribute Details
+ (Hash{Symbol=>BaseDB}) db_classes (readonly)
A Hash holding subclasses of RStore::BaseDB
23 24 25 |
# File 'lib/rstore/base_db.rb', line 23 def db_classes @db_classes end |
Class Method Details
+ connect {|db| ... }
Note:
To be called when defining a subclass of RStore::BaseDB
This method returns an undefined value.
Uses the connection info from info to connect to the database.
103 104 105 |
# File 'lib/rstore/base_db.rb', line 103 def self.connect &block Sequel.connect(@connection_info, &block) end |
+ info(options)
Note:
To be called when defining a subclass of RStore::BaseDB
Define the database connection. Accepts the same one arity parameters as Sequel.connect
58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/rstore/base_db.rb', line 58 def self.info hash_or_string # self = CompanyDB class << self # self = #<Class:CompanyDB> attr_reader :connection_info end # Instance variables always belong to self. @connection_info = hash_or_string.is_a?(Hash) ? hash_or_string.merge(:database => self.name.to_s): hash_or_string end |
+ (Symbol) name
The lower-case class name without the DB postfix
117 118 119 |
# File 'lib/rstore/base_db.rb', line 117 def self.name super.gsub!(/DB/,'').downcase.to_sym end |