Sha256: 62e1577840b704616830f237cb0d412f4f5d5648dcacd488d4c9a2d2baae9587

Contents?: true

Size: 1.17 KB

Versions: 17

Compression:

Stored size: 1.17 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
    to_one    :default_space, :as => :space

    attribute :guid # guid is explicitly set for users

    def guid
      @guid
    end

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

    alias :admin? :admin

    # 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

17 entries across 17 versions & 1 rubygems

Version Path
cfoundry-0.3.23 lib/cfoundry/v2/user.rb
cfoundry-0.3.22 lib/cfoundry/v2/user.rb
cfoundry-0.3.21 lib/cfoundry/v2/user.rb
cfoundry-0.3.20 lib/cfoundry/v2/user.rb
cfoundry-0.3.19 lib/cfoundry/v2/user.rb
cfoundry-0.3.18 lib/cfoundry/v2/user.rb
cfoundry-0.3.17 lib/cfoundry/v2/user.rb
cfoundry-0.3.16 lib/cfoundry/v2/user.rb
cfoundry-0.3.15 lib/cfoundry/v2/user.rb
cfoundry-0.3.14 lib/cfoundry/v2/user.rb
cfoundry-0.3.13 lib/cfoundry/v2/user.rb
cfoundry-0.3.12 lib/cfoundry/v2/user.rb
cfoundry-0.3.11 lib/cfoundry/v2/user.rb
cfoundry-0.3.10 lib/cfoundry/v2/user.rb
cfoundry-0.3.9 lib/cfoundry/v2/user.rb
cfoundry-0.3.8 lib/cfoundry/v2/user.rb
cfoundry-0.3.7 lib/cfoundry/v2/user.rb