Class: Warrant::User

Inherits:
Object show all
Includes:
WarrantObject
Defined in:
lib/warrant/models/user.rb

Constant Summary collapse

OBJECT_TYPE =
"user"

Instance Attribute Summary

Attributes inherited from Object

#created_at, #meta, #object_id, #object_type

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.assign_to_tenant(tenant_id, user_id, relation: "member", options: {}) ⇒ Warrant

Add a user to a tenant

Parameters:

  • tenant_id (String)

    The tenant_id of the tenant you want to assign a user to.

  • user_id (String)

    The user_id of the user you want to add to the tenant.

  • relation (String) (defaults to: "member")

    The relation for this tenant to user association. The relation must be valid as per the tenant object type definition.

Returns:

  • (Warrant)

    warrant assigning user to the tenant

Raises:



369
370
371
# File 'lib/warrant/models/user.rb', line 369

def self.assign_to_tenant(tenant_id, user_id, relation: "member", options: {})
    Warrant.create({ object_type: Tenant::OBJECT_TYPE, object_id: tenant_id }, relation, { object_type: User::OBJECT_TYPE, object_id: user_id }, nil, options)
end

.batch_create(users, options = {}) ⇒ Array<User>

Batch creates multiple users with given parameters

Examples:

Create two new users with user ids “test-user-1” and “test-user-2”

Warrant::User.batch_create([{ user_id: "test-user-1" }, { user_id: "test-user-2" }])

Parameters:

  • users (Array<Hash>)

    Array of users to create.

Options Hash (users):

  • :user_id (String)

    User defined string identifier for this user. If not provided, Warrant will create an id for the user and return it. In this case, you should store the id in your system for future reference. Note that tenantIds in Warrant must be composed of alphanumeric chars and/or ‘-’, ‘_’, and ‘@’. (optional)

  • :meta (Hash)

    A JSON object containing additional information about the user (e.g. name/description, etc.) to be persisted to Warrant. (optional)

Returns:

  • (Array<User>)

    all created users

Raises:



54
55
56
57
# File 'lib/warrant/models/user.rb', line 54

def self.batch_create(users, options = {})
    res = Object.batch_create(users.map{ |user| { object_type: OBJECT_TYPE, object_id: user[:user_id], meta: user[:meta] }}, options)
    return res.map{ |obj| User.new(obj.object_id, obj.meta, obj.created_at)}
end

.batch_delete(users, options = {}) ⇒ nil

Batch deletes multiple users with given parameters

Examples:

Delete two users with ids “test-user-1” and “test-user-2”

Warrant::User.batch_delete([{ user_id: "test-user-1" }, { user_id: "test-user-2" }])

Parameters:

  • users (Array<Hash, User>)

    Array of users to delete.

Options Hash (users):

  • :user_id (String)

    Customer defined string identifier for this user.

Returns:

  • (nil)

    if delete was successful

Raises:



90
91
92
93
94
95
96
97
98
# File 'lib/warrant/models/user.rb', line 90

def self.batch_delete(users, options = {})
    return Object.batch_delete(users.map{ |user|
        if user.instance_of? User
            { object_type: OBJECT_TYPE, object_id: user.object_id }
        else
            { object_type: OBJECT_TYPE, object_id: user[:user_id] }
        end
    }, options)
end

.create(params = {}, options = {}) ⇒ User

Creates a user with the given parameters

Examples:

Create a new User with the user id “test-customer”

Warrant::User.create(user_id: "test-customer")

Parameters:

  • params (Hash) (defaults to: {})

    a customizable set of options

Options Hash (params):

  • :user_id (String)

    User defined string identifier for this user. If not provided, Warrant will create an id for the user and return it. In this case, you should store the id in your system as you will need to provide it for any authorization requests for that user. Note that userIds in Warrant must be composed of alphanumeric chars and/or ‘-’, ‘_’, and ‘@’. (optional)

  • :meta (Hash)

    A JSON object containing additional information about this user (e.g. email/name) to be persisted to Warrant. (optional)

Returns:

  • (User)

    created user

Raises:



32
33
34
35
# File 'lib/warrant/models/user.rb', line 32

def self.create(params = {}, options = {})
    object = Object.create({ object_type: OBJECT_TYPE, object_id: params[:user_id], meta: params[:meta] }, options)
    return User.new(object.object_id, object.meta, object.created_at)
end

.delete(user_id, options = {}) ⇒ nil

Deletes a user with given user id

Examples:

Delete a User with the user id “test-customer”

Warrant::User.delete("test-customer")

Parameters:

  • user_id (String)

    User defined string identifier for this user.

Returns:

  • (nil)

    if delete was successful

Raises:



72
73
74
# File 'lib/warrant/models/user.rb', line 72

def self.delete(user_id, options = {})
    return Object.delete(OBJECT_TYPE, user_id, options)
end

.get(user_id, options = {}) ⇒ User

Get a user with the given user_id

Parameters:

  • user_id (String)

    User defined string identifier for this user. If not provided, Warrant will create an id for the user and return it. In this case, you should store the id in your system as you will need to provide it for any authorization requests for that user. Note that userIds in Warrant must be composed of alphanumeric chars and/or ‘-’, ‘_’, and ‘@’.

Returns:

  • (User)

    retrieved user

Raises:



136
137
138
139
# File 'lib/warrant/models/user.rb', line 136

def self.get(user_id, options = {})
    object = Object.get(OBJECT_TYPE, user_id, options)
    return User.new(object.object_id, object.meta, object.created_at)
end

.list(filters = {}, options = {}) ⇒ Array<User>

Lists all users for your organization

Examples:

List all users

Warrant::User.list()

Parameters:

  • filters (Hash) (defaults to: {})

    Filters to apply to result set

  • options (Hash) (defaults to: {})

    Options to apply on a per-request basis

Options Hash (filters):

  • :limit (Integer)

    A positive integer representing the maximum number of items to return in the response. Must be less than or equal to 1000. Defaults to 25. (optional)

  • :prev_cursor (String)

    A cursor representing your place in a list of results. Requests containing prev_cursor will return the results immediately preceding the cursor. (optional)

  • :next_cursor (String)

    A cursor representing your place in a list of results. Requests containing next_cursor will return the results immediately following the cursor. (optional)

  • :sort_by (String)

    The column to sort the result by. Unless otherwise specified, all list endpoints are sorted by their unique identifier by default. Supported values for objects are object_type, object_id, and created_at (optional)

  • :sort_order (String)

    The order in which to sort the result by. Valid values are ASC and DESC. Defaults to ASC. (optional)

Options Hash (options):

  • :warrant_token (String)

    A valid warrant token from a previous write operation or latest. Used to specify desired consistency for this read operation. (optional)

Returns:

  • (Array<User>)

    all users for your organization

Raises:



119
120
121
122
123
124
# File 'lib/warrant/models/user.rb', line 119

def self.list(filters = {}, options = {})
    filters.merge({ object_type: "user" })
    list_response = Object.list(filters, options)
    users = list_response.results.map{ |object| User.new(object.object_id, object.meta, object.created_at)}
    return ListResponse.new(users, list_response.prev_cursor, list_response.next_cursor)
end

.list_for_tenant(tenant_id, filters = {}, options = {}) ⇒ Array<User>

List all users for a tenant

Parameters:

  • tenant_id (String)

    The tenant_id of the tenant from which to fetch users

  • filters (Hash) (defaults to: {})

    Filters to apply to result set

  • options (Hash) (defaults to: {})

    Options to apply on a per-request basis

Options Hash (filters):

  • :object_type (String)

    Only return objects with an ‘objectType` matching this value

  • :limit (Integer)

    A positive integer representing the maximum number of items to return in the response. Must be less than or equal to 1000. Defaults to 25. (optional)

  • :prev_cursor (String)

    A cursor representing your place in a list of results. Requests containing prev_cursor will return the results immediately preceding the cursor. (optional)

  • :next_cursor (String)

    A cursor representing your place in a list of results. Requests containing next_cursor will return the results immediately following the cursor. (optional)

  • :sort_by (String)

    The column to sort the result by. Unless otherwise specified, all list endpoints are sorted by their unique identifier by default. Supported values for objects are object_type, object_id, and created_at (optional)

  • :sort_order (String)

    The order in which to sort the result by. Valid values are ASC and DESC. Defaults to ASC. (optional)

Options Hash (options):

  • :warrant_token (String)

    A valid warrant token from a previous write operation or latest. Used to specify desired consistency for this read operation. (optional)

Returns:

  • (Array<User>)

    all users for the tenant

Raises:



350
351
352
353
354
# File 'lib/warrant/models/user.rb', line 350

def self.list_for_tenant(tenant_id, filters = {}, options = {})
    query_response = Warrant.query("select * of type user for tenant:#{tenant_id}", filters: filters, options: options)
    users = query_response.results.map{ |result| User.new(result.object_id, result.meta) }
    return ListResponse.new(users, query_response.prev_cursor, query_response.next_cursor)
end

.remove_from_tenant(tenant_id, user_id, relation: "member", options: {}) ⇒ nil

Remove a user from a tenant

Parameters:

  • tenant_id (String)

    The tenant_id of the tenant you want to remove the user from.

  • user_id (String)

    The user_id of the user you want to remove from the tenant.

  • relation (String) (defaults to: "member")

    The relation for this tenant to user association. The relation must be valid as per the tenant object type definition.

Returns:

  • (nil)

    if remove was successful

Raises:



385
386
387
# File 'lib/warrant/models/user.rb', line 385

def self.remove_from_tenant(tenant_id, user_id, relation: "member", options: {})
    Warrant.delete({ object_type: Tenant::OBJECT_TYPE, object_id: tenant_id }, relation, { object_type: User::OBJECT_TYPE, object_id: user_id }, nil, options)
end

.update(user_id, meta, options = {}) ⇒ User

Updates a user with the given user_id

Examples:

Update user “test-user”‘s email

Warrant::User.update("test-user", { email: "[email protected]" })

Parameters:

  • user_id (String)

    User defined string identifier for this user.

  • meta (Hash)

    A JSON object containing additional information about this user (e.g. name/description, etc.) to be persisted to Warrant.

Returns:

  • (User)

    updated user

Raises:



156
157
158
159
# File 'lib/warrant/models/user.rb', line 156

def self.update(user_id, meta, options = {})
    object = Object.update(OBJECT_TYPE, user_id, meta, options)
    return User.new(object.object_id, object.meta, object.created_at)
end

Instance Method Details

#assign_feature(feature_id, relation: "member", options: {}) ⇒ Feature

Assign a feature to a user

Parameters:

  • feature_id (String)

    The feature_id of the feature you want to assign to the user.

  • relation (String) (defaults to: "member")

    The relation for this feature to user association. The relation must be valid as per the feature object type definition.

Returns:

Raises:



497
498
499
# File 'lib/warrant/models/user.rb', line 497

def assign_feature(feature_id, relation: "member", options: {})
    return Feature.assign_to_user(user_id, feature_id, relation: relation, options: options)
end

#assign_permission(permission_id, relation: "member", options: {}) ⇒ Permission

Assign a permission to a user

Examples:

user = Warrant::User.get("fawa324nfa")
user.assign_permission("edit-report")

Parameters:

  • permission_id (String)

    The permission_id of the permission you want to assign to a user.

  • relation (String) (defaults to: "member")

    The relation for this permission to user association. The relation must be valid as per the permission object type definition.

Returns:

Raises:



282
283
284
# File 'lib/warrant/models/user.rb', line 282

def assign_permission(permission_id, relation: "member", options: {})
    return Permission.assign_to_user(user_id, permission_id, relation: relation, options: options)
end

#assign_pricing_tier(pricing_tier_id, relation: "member", options: {}) ⇒ PricingTier

Assign a pricing tier to a user

Parameters:

  • pricing_tier_id (String)

    The pricing_tier_id of the pricing tier you want to assign to the user.

  • relation (String) (defaults to: "member")

    The relation for this pricing tier to user association. The relation must be valid as per the pricing tier object type definition.

Returns:

Raises:



444
445
446
# File 'lib/warrant/models/user.rb', line 444

def assign_pricing_tier(pricing_tier_id, relation: "member", options: {})
    return PricingTier.assign_to_user(user_id, pricing_tier_id, relation: relation, options: options)
end

#assign_role(role_id, relation: "member", options: {}) ⇒ Permission

Assign a role to a user

Examples:

user = Warrant::User.get("fawa324nfa")
user.assign_role("admin")

Parameters:

  • user_id (String)

    The user_id of the user you want to assign a role to.

  • role_id (String)

    The role_id of the role you want to assign to a user.

  • relation (String) (defaults to: "member")

    The relation for this role to user association. The relation must be valid as per the role object type definition.

Returns:

Raises:



219
220
221
# File 'lib/warrant/models/user.rb', line 219

def assign_role(role_id, relation: "member", options: {})
    return Role.assign_to_user(user_id, role_id, relation: relation, options: options)
end

#has_feature?(feature_id, relation: "member", options: {}) ⇒ Boolean

Check whether a user has a given feature

Parameters:

  • feature_id (String)

    The feature_id of the feature to check whether the user has access to.

  • relation (String) (defaults to: "member")

    The relation for this feature to user association. The relation must be valid as per the feature object type definition.

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options:):

  • :context (Hash)

    Object containing key-value pairs that specifies the context the warrant should be checked in. (optional)

  • :debug (Boolean)

    Boolean flag indicating whether or not to return debug information for this access check. Defaults to false. (optional)

Returns:

  • (Boolean)

    whether or not the user has the given feature

Raises:



530
531
532
533
534
535
536
537
538
539
540
541
# File 'lib/warrant/models/user.rb', line 530

def has_feature?(feature_id, relation: "member", options: {})
    return Warrant.has_feature?({
        feature_id: feature_id,
        relation: relation,
        subject: {
            object_type: "user",
            object_id: user_id
        },
        context: options[:context],
        debug: options[:debug]
    }, options)
end

#has_permission?(permission_id, relation: "member", options: {}) ⇒ Boolean

Checks whether a user has a given permission

Examples:

user = Warrant::User.get("fawa324nfa")
user.has_permission?("edit-report")

Parameters:

  • permission_id (String)

    The permission_id of the permission you want to check whether or not it exists on the user.

  • relation (String) (defaults to: "member")

    The relation for this permission to user association. The relation must be valid as per the permission object type definition.

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options:):

  • :context (Hash)

    Object containing key-value pairs that specifies the context the warrant should be checked in. (optional)

  • :debug (Boolean)

    Boolean flag indicating whether or not to return debug information for this access check. Defaults to false. (optional)

Returns:

  • (Boolean)

    whether or not the user has the given permission

Raises:



322
323
324
325
326
327
328
329
330
# File 'lib/warrant/models/user.rb', line 322

def has_permission?(permission_id, relation: "member", options: {})
    return Warrant.user_has_permission?({
        permission_id: permission_id,
        relation: relation,
        user_id: user_id,
        context: options[:context],
        debug: options[:debug]
    }, options)
end

#list_features(filters = {}, options = {}) ⇒ Array<Feature>

List features for a user

Parameters:

  • filters (Hash) (defaults to: {})

    Filters to apply to result set

  • options (Hash) (defaults to: {})

    Options to apply on a per-request basis

Options Hash (filters):

  • :object_type (String)

    Only return objects with an ‘objectType` matching this value

  • :limit (Integer)

    A positive integer representing the maximum number of items to return in the response. Must be less than or equal to 1000. Defaults to 25. (optional)

  • :prev_cursor (String)

    A cursor representing your place in a list of results. Requests containing prev_cursor will return the results immediately preceding the cursor. (optional)

  • :next_cursor (String)

    A cursor representing your place in a list of results. Requests containing next_cursor will return the results immediately following the cursor. (optional)

  • :sort_by (String)

    The column to sort the result by. Unless otherwise specified, all list endpoints are sorted by their unique identifier by default. Supported values for objects are object_type, object_id, and created_at (optional)

  • :sort_order (String)

    The order in which to sort the result by. Valid values are ASC and DESC. Defaults to ASC. (optional)

Options Hash (options):

  • :warrant_token (String)

    A valid warrant token from a previous write operation or latest. Used to specify desired consistency for this read operation. (optional)

Returns:

  • (Array<Feature>)

    assigned features for the user

Raises:



481
482
483
# File 'lib/warrant/models/user.rb', line 481

def list_features(filters = {}, options = {})
    return Feature.list_for_user(user_id, filters, options)
end

#list_permissions(filters = {}, options = {}) ⇒ Array<Permission>

List all permissions for a user

Parameters:

  • filters (Hash) (defaults to: {})

    Filters to apply to result set

  • options (Hash) (defaults to: {})

    Options to apply on a per-request basis

Options Hash (filters):

  • :object_type (String)

    Only return objects with an ‘objectType` matching this value

  • :limit (Integer)

    A positive integer representing the maximum number of items to return in the response. Must be less than or equal to 1000. Defaults to 25. (optional)

  • :prev_cursor (String)

    A cursor representing your place in a list of results. Requests containing prev_cursor will return the results immediately preceding the cursor. (optional)

  • :next_cursor (String)

    A cursor representing your place in a list of results. Requests containing next_cursor will return the results immediately following the cursor. (optional)

  • :sort_by (String)

    The column to sort the result by. Unless otherwise specified, all list endpoints are sorted by their unique identifier by default. Supported values for objects are object_type, object_id, and created_at (optional)

  • :sort_order (String)

    The order in which to sort the result by. Valid values are ASC and DESC. Defaults to ASC. (optional)

Options Hash (options):

  • :warrant_token (String)

    A valid warrant token from a previous write operation or latest. Used to specify desired consistency for this read operation. (optional)

Returns:

  • (Array<Permission>)

    all permissions for the user

Raises:



261
262
263
# File 'lib/warrant/models/user.rb', line 261

def list_permissions(filters = {}, options = {})
    return Permission.list_for_user(user_id, filters, options)
end

#list_pricing_tiers(filters = {}, options = {}) ⇒ Array<PricingTier>

List pricing tiers for a user

Parameters:

  • filters (Hash) (defaults to: {})

    Filters to apply to result set

  • options (Hash) (defaults to: {})

    Options to apply on a per-request basis

Options Hash (filters):

  • :object_type (String)

    Only return objects with an ‘objectType` matching this value

  • :limit (Integer)

    A positive integer representing the maximum number of items to return in the response. Must be less than or equal to 1000. Defaults to 25. (optional)

  • :prev_cursor (String)

    A cursor representing your place in a list of results. Requests containing prev_cursor will return the results immediately preceding the cursor. (optional)

  • :next_cursor (String)

    A cursor representing your place in a list of results. Requests containing next_cursor will return the results immediately following the cursor. (optional)

  • :sort_by (String)

    The column to sort the result by. Unless otherwise specified, all list endpoints are sorted by their unique identifier by default. Supported values for objects are object_type, object_id, and created_at (optional)

  • :sort_order (String)

    The order in which to sort the result by. Valid values are ASC and DESC. Defaults to ASC. (optional)

Options Hash (options):

  • :warrant_token (String)

    A valid warrant token from a previous write operation or latest. Used to specify desired consistency for this read operation. (optional)

Returns:

  • (Array<PricingTier>)

    assigned pricing tiers for the user

Raises:



428
429
430
# File 'lib/warrant/models/user.rb', line 428

def list_pricing_tiers(filters = {}, options = {})
    return PricingTier.list_for_user(user_id, filters, options)
end

#list_roles(filters = {}, options = {}) ⇒ Array<Role>

List all roles for a user.

Parameters:

  • filters (Hash) (defaults to: {})

    Filters to apply to result set

  • options (Hash) (defaults to: {})

    Options to apply on a per-request basis

Options Hash (filters):

  • :object_type (String)

    Only return objects with an ‘objectType` matching this value

  • :limit (Integer)

    A positive integer representing the maximum number of items to return in the response. Must be less than or equal to 1000. Defaults to 25. (optional)

  • :prev_cursor (String)

    A cursor representing your place in a list of results. Requests containing prev_cursor will return the results immediately preceding the cursor. (optional)

  • :next_cursor (String)

    A cursor representing your place in a list of results. Requests containing next_cursor will return the results immediately following the cursor. (optional)

  • :sort_by (String)

    The column to sort the result by. Unless otherwise specified, all list endpoints are sorted by their unique identifier by default. Supported values for objects are object_type, object_id, and created_at (optional)

  • :sort_order (String)

    The order in which to sort the result by. Valid values are ASC and DESC. Defaults to ASC. (optional)

Options Hash (options):

  • :warrant_token (String)

    A valid warrant token from a previous write operation or latest. Used to specify desired consistency for this read operation. (optional)

Returns:

  • (Array<Role>)

    all roles for the user

Raises:



197
198
199
# File 'lib/warrant/models/user.rb', line 197

def list_roles(filters = {}, options = {})
    return Role.list_for_user(user_id, filters, options)
end

#list_tenants(filters = {}, options = {}) ⇒ Array<Tenant>

List all tenants for a user

Parameters:

  • filters (Hash) (defaults to: {})

    Filters to apply to result set

  • options (Hash) (defaults to: {})

    Options to apply on a per-request basis

Options Hash (filters):

  • :object_type (String)

    Only return objects with an ‘objectType` matching this value

  • :limit (Integer)

    A positive integer representing the maximum number of items to return in the response. Must be less than or equal to 1000. Defaults to 25. (optional)

  • :prev_cursor (String)

    A cursor representing your place in a list of results. Requests containing prev_cursor will return the results immediately preceding the cursor. (optional)

  • :next_cursor (String)

    A cursor representing your place in a list of results. Requests containing next_cursor will return the results immediately following the cursor. (optional)

  • :sort_by (String)

    The column to sort the result by. Unless otherwise specified, all list endpoints are sorted by their unique identifier by default. Supported values for objects are object_type, object_id, and created_at (optional)

  • :sort_order (String)

    The order in which to sort the result by. Valid values are ASC and DESC. Defaults to ASC. (optional)

Options Hash (options):

  • :warrant_token (String)

    A valid warrant token from a previous write operation or latest. Used to specify desired consistency for this read operation. (optional)

Returns:

  • (Array<Tenant>)

    all tenants for the user

Raises:



407
408
409
# File 'lib/warrant/models/user.rb', line 407

def list_tenants(filters = {}, options = {})
    return Tenant.list_for_user(user_id, filters, options)
end

#remove_feature(feature_id, relation: "member", options: {}) ⇒ nil

Remove a feature from a user

Parameters:

  • feature_id (String)

    The feature_id of the feature you want to assign from the user.

  • relation (String) (defaults to: "member")

    The relation for this feature to user association. The relation must be valid as per the feature object type definition.

Returns:

  • (nil)

    if remove was successful

Raises:



513
514
515
# File 'lib/warrant/models/user.rb', line 513

def remove_feature(feature_id, relation: "member", options: {})
    return Feature.remove_from_user(user_id, feature_id, relation: relation, options: options)
end

#remove_permission(permission_id, relation: "member", options: {}) ⇒ nil

Remove a permission from a user

Examples:

user = Warrant::User.get("fawa324nfa")
user.remove_permission("edit-report")

Parameters:

  • permission_id (String)

    The permission_id of the permission you want to assign to a user.

  • relation (String) (defaults to: "member")

    The relation for this permission to user association. The relation must be valid as per the permission object type definition.

Returns:

  • (nil)

    if remove was successful

Raises:



301
302
303
# File 'lib/warrant/models/user.rb', line 301

def remove_permission(permission_id, relation: "member", options: {})
    Permission.remove_from_user(user_id, permission_id, relation: relation, options: options)
end

#remove_pricing_tier(pricing_tier_id, relation: "member", options: {}) ⇒ nil

Remove a pricing tier from a user

Parameters:

  • pricing_tier_id (String)

    The pricing_tier_id of the pricing tier you want to assign from the user.

  • relation (String) (defaults to: "member")

    The relation for this pricing tier to user association. The relation must be valid as per the pricing tier object type definition.

Returns:

  • (nil)

    if remove was successful

Raises:



460
461
462
# File 'lib/warrant/models/user.rb', line 460

def remove_pricing_tier(pricing_tier_id, relation: "member", options: {})
    return PricingTier.remove_from_user(user_id, pricing_tier_id, relation: relation, options: options)
end

#remove_role(role_id, relation: "member", options: {}) ⇒ nil

Remove a role from a user

Examples:

user = Warrant::User.get("fawa324nfa")
user.remove_role("admin")

Parameters:

  • user_id (String)

    The user_id of the role you want to assign a role to.

  • role_id (String)

    The role_id of the role you want to assign to a user.

  • relation (String) (defaults to: "member")

    The relation for this role to user association. The relation must be valid as per the role object type definition.

Returns:

  • (nil)

    if remove was successful

Raises:



240
241
242
# File 'lib/warrant/models/user.rb', line 240

def remove_role(role_id, relation: "member", options: {})
    return Role.remove_from_user(user_id, role_id, relation: relation, options: options)
end

#update(meta, options = {}) ⇒ User

Updates the user with the given params

Examples:

Update user “test-user”‘s email

user = Warrant::User.get("test-user")
user.update({ email: "[email protected]" })

Parameters:

  • meta (Hash)

    A JSON object containing additional information about this user (e.g. name/description, etc.) to be persisted to Warrant.

Returns:

  • (User)

    updated user

Raises:



176
177
178
# File 'lib/warrant/models/user.rb', line 176

def update(meta, options = {})
    return User.update(user_id, meta, options)
end

#warrant_object_idObject



547
548
549
# File 'lib/warrant/models/user.rb', line 547

def warrant_object_id
    user_id
end

#warrant_object_typeObject



543
544
545
# File 'lib/warrant/models/user.rb', line 543

def warrant_object_type
    "user"
end