Module: Reorm

Defined in:
lib/reorm/model.rb,
lib/reorm.rb,
lib/reorm/cursor.rb,
lib/reorm/version.rb,
lib/reorm/exceptions.rb,
lib/reorm/field_path.rb,
lib/reorm/configuration.rb,
lib/reorm/property_errors.rb,
lib/reorm/validators/validator.rb,
lib/reorm/modules/event_modules.rb,
lib/reorm/modules/database_modules.rb,
lib/reorm/modules/validation_modules.rb,
lib/reorm/validators/presence_validator.rb,
lib/reorm/validators/exclusion_validator.rb,
lib/reorm/validators/inclusion_validator.rb,
lib/reorm/validators/maximum_length_validator.rb,
lib/reorm/validators/minimum_length_validator.rb

Overview

! /usr/bin/env ruby Copyright ©, 2015 Peter Wood See the license.txt for details of the licensing of the code in this file.

Defined Under Namespace

Modules: ClassDatabaseSettings, EventData, EventHandler, EventSource, PrimaryKeyedClassMethods, PrimaryKeyedInstanceMethods, SpecifyEventHandlers, TableBacked, Timestamped, Validations Classes: Configuration, Cursor, Error, ExclusionValidator, FieldPath, InclusionValidator, MaximumLengthValidator, MinimumLengthValidator, Model, PresenceValidator, PropertyErrors, Validator

Constant Summary collapse

DEFAULT_SIZE =

Constants used with Rethinkdb connections.

5
DEFAULT_TIMEOUT =
5
SETTINGS_NAMES =
[:host, :port, :db, :auth_key, :timeout]
MAJOR_VERSION =
0
MINOR_VERSION =
1
BUILD_VERSION =
13
VERSION =
"#{MAJOR_VERSION}.#{MINOR_VERSION}.#{BUILD_VERSION}"
@@reorm_connections =

Module property containing the connection pool.

ConnectionPool.new(size:    Configuration.fetch(:size, DEFAULT_SIZE),
                   timeout: Configuration.fetch(:timeout, DEFAULT_TIMEOUT)) do
  settings = Configuration.instance.to_h.inject({}) do |store, entry|
               store[entry[0]] = entry[1] if SETTINGS_NAMES.include?(entry[0])
               store
             end
  r.connect(settings)
end

Class Method Summary collapse

Class Method Details

.connectionObject

A method for obtaining a connection from the module connection pool. The intended usage is that you call this method with a block that will be passed the connection as a parameter.



42
43
44
45
46
# File 'lib/reorm.rb', line 42

def self.connection
  @@reorm_connections.with do |connection|
    yield connection
  end
end