Class: MongoModel::URIConfiguration

Inherits:
Object
  • Object
show all
Defined in:
lib/mongomodel/support/configuration.rb

Instance Method Summary collapse

Constructor Details

#initialize(uri) ⇒ URIConfiguration


73
74
75
# File 'lib/mongomodel/support/configuration.rb', line 73

def initialize(uri)
  @uri = uri
end

Instance Method Details

#connectionObject


93
94
95
# File 'lib/mongomodel/support/configuration.rb', line 93

def connection
  @connection ||= parser.connection({})
end

#databaseObject


85
86
87
# File 'lib/mongomodel/support/configuration.rb', line 85

def database
  parser.connection_options[:db_name]
end

#establish_connectionObject


89
90
91
# File 'lib/mongomodel/support/configuration.rb', line 89

def establish_connection
  @database = connection.db
end

#hostObject


77
78
79
# File 'lib/mongomodel/support/configuration.rb', line 77

def host
  parser.host
end

#parserObject


97
98
99
# File 'lib/mongomodel/support/configuration.rb', line 97

def parser
  @parser ||= Mongo::URIParser.new(@uri)
end

#portObject


81
82
83
# File 'lib/mongomodel/support/configuration.rb', line 81

def port
  parser.port
end