Class: Configure

Inherits:
Object
  • Object
show all
Defined in:
lib/wherever/configure.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Configure

Returns a new instance of Configure.



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/wherever/configure.rb', line 3

def initialize(options)
  host = options["host"] || 'localhost'
  database = options["database"] || 'wherever'
  user = options["user"]
  password = options["password"]
  @_id = options["key"] ||= "unqiue_id"

  Mongoid.config do |config|
    mongo_connection = Mongo::Connection.new(host).db(database)
    mongo_connection.authenticate(user, password) if user
    config.master = mongo_connection
  end

  @keys = StringHelper.add_method_to_id(options["keys"], false)
  @key_groups = StringHelper.add_method_to_id(options["key_groups"] || options["keys"])
end

Instance Attribute Details

#_idObject

Returns the value of attribute _id.



2
3
4
# File 'lib/wherever/configure.rb', line 2

def _id
  @_id
end

#key_groupsObject

Returns the value of attribute key_groups.



2
3
4
# File 'lib/wherever/configure.rb', line 2

def key_groups
  @key_groups
end

#keysObject

Returns the value of attribute keys.



2
3
4
# File 'lib/wherever/configure.rb', line 2

def keys
  @keys
end