Class: Warren::Connection
- Inherits:
-
Object
- Object
- Warren::Connection
- Defined in:
- lib/warren/connection.rb
Constant Summary collapse
- InvalidConnectionDetails =
Raised if connection details are missing or invalid Check the error message for more details
Class.new(Exception)
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(params = nil) ⇒ Connection
constructor
Creates a new connection by reading the options from WARREN_ROOT/config/warren.yml or specify the file to read as an argument or by passing a hash of connection details in.
Constructor Details
#initialize(params = nil) ⇒ Connection
Creates a new connection by reading the options from WARREN_ROOT/config/warren.yml or specify the file to read as an argument or by passing a hash of connection details in.
Warren::Connection.new # reads WARREN_ROOT/config/warren.yml
Warren::Connection.new("file.yml") # reads file.yml
Warren::Connection.new({"foo" => "bar"}) # uses the hash
Reads WARREN_ENV out of the yaml’d hash (just like ActiveRecord) “development” by default (and RAILS_ENV if running under rails)
Raises InvalidConnectionDetails if no params are found for the current environment.
todo: fail nicely if the env isn’t defined
24 25 26 27 28 |
# File 'lib/warren/connection.rb', line 24 def initialize params = nil get_connection_details(params) # Make the details publically accessible @options = @opts end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/warren/connection.rb', line 5 def @options end |