Sha256: c81c9100cddcb0e9ff465061dcd52f815298894bbc9fc37347e5ec913358f3eb
Contents?: true
Size: 1.19 KB
Versions: 2
Compression:
Stored size: 1.19 KB
Contents
module Scrivito # @api public # Represents a Membership of a {User} in a {Workspace} class Membership # @api public # The {User User's} id # # @return [String] attr_reader :user_id # @api public # The role associated with this membership. # # @note Currently the only available role is "owner". # # @return [String] the name of role attr_reader :role def initialize(user_id, data) @user_id = user_id @role = data.fetch("role") end # Fetches and returns the {User} with the id {Membership#user_id}. # Uses the proc set in {Configuration.find_user} to fetch the user. # @api public # @return The value returned by the proc set in {Configuration.find_user}. # @return An unknown user if no proc is set in {Configuration.find_user} or the proc returns a # falsy value. The unknown user will have the id of the original user and no abilities. # @see Scrivito::Configuration.find_user def user User.find(user_id) || User.unknown_user(user_id) end def as_json(options = nil) { user_id: user_id, role: role, description: user.description, } end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
scrivito_sdk-0.18.1 | lib/scrivito/membership.rb |
scrivito_sdk-0.18.0 | lib/scrivito/membership.rb |