Class: Mongify::Configuration
- Inherits:
-
Object
- Object
- Mongify::Configuration
- Defined in:
- lib/mongify/configuration.rb
Overview
Handles all tasks regarding the connection to sql and no-sql database It also handles the parsing of the data
Class Attribute Summary collapse
-
.in_stream ⇒ Object
Returns the value of attribute in_stream.
-
.out_stream ⇒ Object
Returns the value of attribute out_stream.
Class Method Summary collapse
-
.parse(file_name) ⇒ Object
Parses a external configuration file and evaluates it and returns a instence of a configuration class.
Instance Method Summary collapse
-
#mongodb_connection(options = {}, &block) ⇒ Object
Returns a no_sql_connection which is bound to a mongodb adapter or builds a new no_sql_connection if block is given.
-
#no_sql_connection(options = {}, &block) ⇒ Object
Returns a sql_connection If a block is given, it will be executed on the connection For more information, see Database::NoSqlConnection.
-
#sql_connection(options = {}, &block) ⇒ Object
Returns a sql_connection If a block is given, it will be executed on the connection For more information, see Database::SqlConnection.
Class Attribute Details
.in_stream ⇒ Object
Returns the value of attribute in_stream.
8 9 10 |
# File 'lib/mongify/configuration.rb', line 8 def in_stream @in_stream end |
.out_stream ⇒ Object
Returns the value of attribute out_stream.
8 9 10 |
# File 'lib/mongify/configuration.rb', line 8 def out_stream @out_stream end |
Class Method Details
.parse(file_name) ⇒ Object
Parses a external configuration file and evaluates it and returns a instence of a configuration class
11 12 13 14 15 16 |
# File 'lib/mongify/configuration.rb', line 11 def parse(file_name) raise Mongify::ConfigurationFileNotFound, "File #{file_name} is missing" unless File.exists?(file_name) config = self.new config.instance_eval(File.read(file_name)) config end |
Instance Method Details
#mongodb_connection(options = {}, &block) ⇒ Object
Returns a no_sql_connection which is bound to a mongodb adapter or builds a new no_sql_connection if block is given
22 23 24 25 26 27 |
# File 'lib/mongify/configuration.rb', line 22 def mongodb_connection(={}, &block) return @mongodb_conncetion if @mongodb_connection and !block_given? .stringify_keys! ['adapter'] ||= 'mongodb' @mongodb_connection = no_sql_connection(, &block) end |
#no_sql_connection(options = {}, &block) ⇒ Object
Returns a sql_connection If a block is given, it will be executed on the connection For more information, see Database::NoSqlConnection
41 42 43 44 45 |
# File 'lib/mongify/configuration.rb', line 41 def no_sql_connection(={}, &block) @no_sql_connection ||= Mongify::Database::NoSqlConnection.new() @no_sql_connection.instance_exec(&block) if block_given? @no_sql_connection end |
#sql_connection(options = {}, &block) ⇒ Object
Returns a sql_connection If a block is given, it will be executed on the connection For more information, see Database::SqlConnection
32 33 34 35 36 |
# File 'lib/mongify/configuration.rb', line 32 def sql_connection(={}, &block) @sql_connection ||= Mongify::Database::SqlConnection.new() @sql_connection.instance_exec(&block) if block_given? @sql_connection end |