Class: Mongo::Auth::User::View
- Inherits:
-
Object
- Object
- Mongo::Auth::User::View
- Extended by:
- Forwardable
- Defined in:
- build/ruby-driver-v2.19/lib/mongo/auth/user/view.rb
Overview
Defines behavior for user related operation on databases.
Instance Attribute Summary collapse
-
#database ⇒ Database
readonly
Database The view’s database.
Instance Method Summary collapse
-
#create(user_or_name, options = {}) ⇒ Result
Create a new user in the database.
-
#info(name, options = {}) ⇒ Array
Get info for a particular user in the database.
-
#initialize(database) ⇒ View
constructor
Initialize the new user view.
-
#remove(name, options = {}) ⇒ Result
Remove a user from the database.
-
#update(user_or_name, options = {}) ⇒ Result
Update a user in the database.
Constructor Details
#initialize(database) ⇒ View
Initialize the new user view.
68 69 70 |
# File 'build/ruby-driver-v2.19/lib/mongo/auth/user/view.rb', line 68 def initialize(database) @database = database end |
Instance Attribute Details
#database ⇒ Database (readonly)
Returns database The view’s database.
29 30 31 |
# File 'build/ruby-driver-v2.19/lib/mongo/auth/user/view.rb', line 29 def database @database end |
Instance Method Details
#create(user_or_name, options = {}) ⇒ Result
Create a new user in the database.
48 49 50 51 52 53 54 55 56 57 58 |
# File 'build/ruby-driver-v2.19/lib/mongo/auth/user/view.rb', line 48 def create(user_or_name, = {}) user = generate(user_or_name, ) execute_operation() do |session| Operation::CreateUser.new( user: user, db_name: database.name, session: session, write_concern: [:write_concern] && WriteConcern.get([:write_concern]), ) end end |
#info(name, options = {}) ⇒ Array
Get info for a particular user in the database.
136 137 138 |
# File 'build/ruby-driver-v2.19/lib/mongo/auth/user/view.rb', line 136 def info(name, = {}) user_query(name, ).documents end |
#remove(name, options = {}) ⇒ Result
Remove a user from the database.
86 87 88 89 90 91 92 93 94 95 |
# File 'build/ruby-driver-v2.19/lib/mongo/auth/user/view.rb', line 86 def remove(name, = {}) execute_operation() do |session| Operation::RemoveUser.new( user_name: name, db_name: database.name, session: session, write_concern: [:write_concern] && WriteConcern.get([:write_concern]), ) end end |
#update(user_or_name, options = {}) ⇒ Result
Update a user in the database.
111 112 113 114 115 116 117 118 119 120 121 |
# File 'build/ruby-driver-v2.19/lib/mongo/auth/user/view.rb', line 111 def update(user_or_name, = {}) user = generate(user_or_name, ) execute_operation() do |session| Operation::UpdateUser.new( user: user, db_name: database.name, session: session, write_concern: [:write_concern] && WriteConcern.get([:write_concern]), ) end end |