Sha256: f41436da6e0a8308dde0ef02dd4c4e42ae1a5838933771756fc02ac465b4626b

Contents?: true

Size: 749 Bytes

Versions: 45

Compression:

Stored size: 749 Bytes

Contents

class User < ActiveRecord::Base

  belongs_to :account, 
             class_name: "OpenStax::Accounts::Account"
  has_many :groups_as_member, through: :account
  has_many_through_groups :groups_as_member, :ownerships,
                          as: :owner, dependent: :destroy

  delegate :username, :first_name, :last_name, :full_name, :title,
           :name, :casual_name, to: :account

  def is_anonymous?
    false
  end

  # OpenStax Accounts "account_user_mapper" methods

  def self.account_to_user(acc)
    acc.is_anonymous? ? \
      AnonymousUser.instance : \
      User.where(:account_id => acc.id).first
  end

  def self.user_to_account(user)
    user.is_anonymous? ? \
      AnonymousAccount.instance : \
      user.account
  end
end

Version data entries

45 entries across 45 versions & 1 rubygems

Version Path
openstax_accounts-6.3.2 spec/dummy/app/models/user.rb
openstax_accounts-6.3.1 spec/dummy/app/models/user.rb
openstax_accounts-6.3.0 spec/dummy/app/models/user.rb
openstax_accounts-6.2.0 spec/dummy/app/models/user.rb
openstax_accounts-6.1.7 spec/dummy/app/models/user.rb
openstax_accounts-6.1.6 spec/dummy/app/models/user.rb
openstax_accounts-6.1.5 spec/dummy/app/models/user.rb
openstax_accounts-6.1.4 spec/dummy/app/models/user.rb
openstax_accounts-6.1.3 spec/dummy/app/models/user.rb
openstax_accounts-6.1.2 spec/dummy/app/models/user.rb
openstax_accounts-6.1.1 spec/dummy/app/models/user.rb
openstax_accounts-6.1.0 spec/dummy/app/models/user.rb
openstax_accounts-6.0.0 spec/dummy/app/models/user.rb
openstax_accounts-5.2.0 spec/dummy/app/models/user.rb
openstax_accounts-5.1.2 spec/dummy/app/models/user.rb
openstax_accounts-5.1.1 spec/dummy/app/models/user.rb
openstax_accounts-5.1.0 spec/dummy/app/models/user.rb
openstax_accounts-5.0.1 spec/dummy/app/models/user.rb
openstax_accounts-5.0.0 spec/dummy/app/models/user.rb
openstax_accounts-4.1.1 spec/dummy/app/models/user.rb