Sha256: 1f8dff61b5ec592fbb4dde4035eecb9673ce2d5b10da7b7f7229a2d01d73a8ed

Contents?: true

Size: 1.06 KB

Versions: 107

Compression:

Stored size: 1.06 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 the 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 capabilities.
    # @see Scrivito::Configuration.find_user
    def user
      User.find(user_id) || User.unknown_user(user_id)
    end
  end
end

Version data entries

107 entries across 107 versions & 1 rubygems

Version Path
scrivito_sdk-1.18.0 app/cms/scrivito/membership.rb
scrivito_sdk-1.18.0.rc1 app/cms/scrivito/membership.rb
scrivito_sdk-1.17.0 app/cms/scrivito/membership.rb
scrivito_sdk-1.17.0.rc3 app/cms/scrivito/membership.rb
scrivito_sdk-1.17.0.rc2 app/cms/scrivito/membership.rb
scrivito_sdk-1.17.0.rc1 app/cms/scrivito/membership.rb
scrivito_sdk-1.16.0 app/cms/scrivito/membership.rb
scrivito_sdk-1.16.0.rc2 app/cms/scrivito/membership.rb
scrivito_sdk-1.16.0.rc1 app/cms/scrivito/membership.rb
scrivito_sdk-1.15.0 app/cms/scrivito/membership.rb
scrivito_sdk-1.15.0.rc2 app/cms/scrivito/membership.rb
scrivito_sdk-1.15.0.rc1 app/cms/scrivito/membership.rb
scrivito_sdk-1.14.0 app/cms/scrivito/membership.rb
scrivito_sdk-1.14.0.rc3 app/cms/scrivito/membership.rb
scrivito_sdk-1.14.0.rc2 app/cms/scrivito/membership.rb
scrivito_sdk-1.14.0.rc1 app/cms/scrivito/membership.rb
scrivito_sdk-1.13.0 app/cms/scrivito/membership.rb
scrivito_sdk-1.13.0.rc2 app/cms/scrivito/membership.rb
scrivito_sdk-1.13.0.rc1 app/cms/scrivito/membership.rb
scrivito_sdk-1.12.0 app/cms/scrivito/membership.rb