Sha256: 4206d22018c239da2ec5cb4e1fe2c63ba13d6f0dcd5d64bb3f5d70da4ee4657a

Contents?: true

Size: 1.29 KB

Versions: 34

Compression:

Stored size: 1.29 KB

Contents

require "cfoundry/v2/model"

module CFoundry::V2
  class User < Model
    to_many   :spaces
    to_many   :organizations
    to_many   :managed_organizations, :as => :organization
    to_many   :billing_managed_organizations, :as => :organization
    to_many   :audited_organizations, :as => :organization
    to_many   :managed_spaces, :as => :space
    to_many   :audited_spaces, :as => :space
    attribute :admin, :boolean
    to_one    :default_space, :as => :space

    attribute :guid, :string # guid is explicitly set for users

    def guid
      @guid
    end

    def guid=(x)
      @guid = x
      super
    end

    alias :admin? :admin

    def change_password!(new, old)
      @client.base.uaa.change_password(@guid, new, old)
    end

    # optional metadata from UAA
    attr_accessor :emails, :name

    def email
      return unless @emails && @emails.first
      @emails.first[:value]
    end

    def given_name
      return unless @name && @name[:givenName] != email
      @name[:givenName]
    end

    def family_name
      return unless @name && @name[:familyName] != email
      @name[:familyName]
    end

    def full_name
      if @name && @name[:fullName]
        @name[:fullName]
      elsif given_name && family_name
        "#{given_name} #{family_name}"
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 2 rubygems

Version Path
cfoundry-0.3.61 lib/cfoundry/v2/user.rb
cfoundry-0.3.60 lib/cfoundry/v2/user.rb
cfoundry-0.3.59 lib/cfoundry/v2/user.rb
cfoundry-0.3.58 lib/cfoundry/v2/user.rb
cfoundry-0.3.57 lib/cfoundry/v2/user.rb
cfoundry-0.3.56 lib/cfoundry/v2/user.rb
cfoundry-0.3.55 lib/cfoundry/v2/user.rb
cfoundry-0.3.54 lib/cfoundry/v2/user.rb
cfoundry-0.3.53 lib/cfoundry/v2/user.rb
cfoundry-0.3.52 lib/cfoundry/v2/user.rb
cfoundry-0.3.51 lib/cfoundry/v2/user.rb
cfoundry-0.3.50 lib/cfoundry/v2/user.rb
cfoundry-0.3.49 lib/cfoundry/v2/user.rb
cfoundry-0.3.48 lib/cfoundry/v2/user.rb
cfoundry-0.3.47 lib/cfoundry/v2/user.rb
cfoundry-0.3.46 lib/cfoundry/v2/user.rb
cfoundry-0.3.45 lib/cfoundry/v2/user.rb
cfoundry-0.3.44 lib/cfoundry/v2/user.rb
cfoundry-0.3.43 lib/cfoundry/v2/user.rb
cfoundry-0.3.42 lib/cfoundry/v2/user.rb