Module: AARRR::Config

Extended by:
Config
Included in:
Config
Defined in:
lib/aarrr/config.rb

Overview

Configures AARRR

Instance Method Summary collapse

Instance Method Details

#connectionObject

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

#databaseObject

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

#eventsObject



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.

Examples:

Define the option.

Config.option(:persist_in_safe_mode, :default => false)

Parameters:

  • name (Symbol)

    The name of the configuration option.

  • options (Hash) (defaults to: {})

    Extras for the option.

Options Hash (options):

  • :default (Object)

    The default value.



23
24
25
26
27
28
29
# File 'lib/aarrr/config.rb', line 23

def option(name, options = {})
  define_method(name) do
    @settings.has_key?(name) ? @settings[name] : options[:default]
  end
  define_method("#{name}=") { |value| @settings[name] = value }
  define_method("#{name}?") { send(name) }
end

#usersObject



58
59
60
# File 'lib/aarrr/config.rb', line 58

def users
  database[user_collection_name]
end