Class: Rmr::Options
Instance Attribute Summary collapse
-
#collection ⇒ Object
readonly
Returns the value of attribute collection.
-
#db ⇒ Object
readonly
Returns the value of attribute db.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#server ⇒ Object
readonly
Returns the value of attribute server.
Instance Method Summary collapse
- #account(identify) ⇒ Object
- #find_account ⇒ Object
-
#initialize(args) ⇒ Options
constructor
A new instance of Options.
- #name ⇒ Object
- #password ⇒ Object
- #read_collection ⇒ Object
Constructor Details
#initialize(args) ⇒ Options
Returns a new instance of Options.
14 15 16 17 18 19 |
# File 'lib/rmr.rb', line 14 def initialize(args) @server = args[:server] || 'localhost' @port = args[:port] || '27017' @db = args[:db] || 'test' @collection = args[:collection] || 'test' end |
Instance Attribute Details
#collection ⇒ Object (readonly)
Returns the value of attribute collection.
12 13 14 |
# File 'lib/rmr.rb', line 12 def collection @collection end |
#db ⇒ Object (readonly)
Returns the value of attribute db.
12 13 14 |
# File 'lib/rmr.rb', line 12 def db @db end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
12 13 14 |
# File 'lib/rmr.rb', line 12 def port @port end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
12 13 14 |
# File 'lib/rmr.rb', line 12 def server @server end |
Instance Method Details
#account(identify) ⇒ Object
27 28 29 |
# File 'lib/rmr.rb', line 27 def account(identify) @identify = identify end |
#find_account ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/rmr.rb', line 31 def find_account hashdata = Hash.new read_collection.find("account" => @identify).each do |value| hashdata.merge! value end return hashdata end |
#name ⇒ Object
39 40 41 |
# File 'lib/rmr.rb', line 39 def name find_account['name'] end |
#password ⇒ Object
43 44 45 |
# File 'lib/rmr.rb', line 43 def password find_account['password'] end |
#read_collection ⇒ Object
21 22 23 24 25 |
# File 'lib/rmr.rb', line 21 def read_collection database = Connection.new(@server, @port).db(@db) collection = database[@collection] return collection end |