Module: AARRR::Config
Overview
Configures AARRR
Instance Method Summary collapse
-
#connection ⇒ Object
Get the Mongo::Connection to use to pull the AARRR metrics data.
-
#connection=(connection) ⇒ Object
Set the Mongo::Connection to use to pull the AARRR metrics data.
-
#database ⇒ Object
Get the Mongo::Database associated with the AARRR metrics data.
-
#database=(database) ⇒ Object
Set the Mongo::Database associated with the AARRR metrics data.
- #events ⇒ Object
-
#option(name, options = {}) ⇒ Object
Define a configuration option with a default.
- #users ⇒ Object
Instance Method Details
#connection ⇒ Object
Get the Mongo::Connection to use to pull the AARRR metrics data
39 40 41 |
# File 'lib/aarrr/config.rb', line 39 def connection @connection || Mongo::Connection.new end |
#connection=(connection) ⇒ Object
Set the Mongo::Connection to use to pull the AARRR metrics data
44 45 46 |
# File 'lib/aarrr/config.rb', line 44 def connection=(connection) @connection = connection end |
#database ⇒ Object
Get the Mongo::Database associated with the AARRR metrics data
49 50 51 |
# File 'lib/aarrr/config.rb', line 49 def database @database || connection.db(database_name) end |
#database=(database) ⇒ Object
Set the Mongo::Database associated with the AARRR metrics data
54 55 56 |
# File 'lib/aarrr/config.rb', line 54 def database=(database) @database = database end |
#events ⇒ Object
62 63 64 |
# File 'lib/aarrr/config.rb', line 62 def events database[event_collection_name] end |
#option(name, options = {}) ⇒ Object
Define a configuration option with a default.
23 24 25 26 27 28 29 |
# File 'lib/aarrr/config.rb', line 23 def option(name, = {}) define_method(name) do @settings.has_key?(name) ? @settings[name] : [:default] end define_method("#{name}=") { |value| @settings[name] = value } define_method("#{name}?") { send(name) } end |
#users ⇒ Object
58 59 60 |
# File 'lib/aarrr/config.rb', line 58 def users database[user_collection_name] end |