Class: Mongo::Auth::User::View
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
Forwardable
|
|
Inherits: | Object |
Defined in: | lib/mongo/auth/user/view.rb |
Overview
Defines behavior for user related operation on databases.
Class Method Summary
-
.new(database) ⇒ View
constructor
Initialize the new user view.
Instance Attribute Summary
- #database ⇒ Database readonly
Instance Method Summary
-
#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.
-
#remove(name, options = {}) ⇒ Result
Remove a user from the database.
-
#update(user_or_name, options = {}) ⇒ Result
Update a user in the database.
- #execute_operation(options) private
- #generate(user, options) private
- #user_query(name, options = {}) private
Constructor Details
.new(database) ⇒ View
Initialize the new user view.
Instance Attribute Details
#database ⇒ Database (readonly)
# File 'lib/mongo/auth/user/view.rb', line 29
attr_reader :database
Instance Method Details
#create(user_or_name, options = {}) ⇒ Result
Create a new user in the database.
# File '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
#execute_operation(options) (private)
#generate(user, options) (private)
#info(name, options = {}) ⇒ Array
Get info for a particular user in the database.
# File '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.
# File '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.
# File '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