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-8.0.0 spec/dummy/app/models/user.rb
openstax_accounts-7.13.1 spec/dummy/app/models/user.rb
openstax_accounts-7.13.0 spec/dummy/app/models/user.rb
openstax_accounts-7.12.0 spec/dummy/app/models/user.rb
openstax_accounts-7.11.0 spec/dummy/app/models/user.rb
openstax_accounts-7.10.0 spec/dummy/app/models/user.rb
openstax_accounts-7.9.0 spec/dummy/app/models/user.rb
openstax_accounts-7.8.0 spec/dummy/app/models/user.rb
openstax_accounts-7.7.0 spec/dummy/app/models/user.rb
openstax_accounts-7.6.0 spec/dummy/app/models/user.rb
openstax_accounts-7.5.0 spec/dummy/app/models/user.rb
openstax_accounts-7.4.0 spec/dummy/app/models/user.rb
openstax_accounts-7.3.0 spec/dummy/app/models/user.rb
openstax_accounts-7.2.0 spec/dummy/app/models/user.rb
openstax_accounts-7.1.0 spec/dummy/app/models/user.rb
openstax_accounts-7.0.1 spec/dummy/app/models/user.rb
openstax_accounts-7.0.0 spec/dummy/app/models/user.rb
openstax_accounts-6.4.2 spec/dummy/app/models/user.rb
openstax_accounts-6.4.1 spec/dummy/app/models/user.rb
openstax_accounts-6.4.0 spec/dummy/app/models/user.rb