Sha256: be68e6ea8ddb402d159c463dbbf89572b043a6b0b23acfeb84d0583aaed5dd23

Contents?: true

Size: 575 Bytes

Versions: 194

Compression:

Stored size: 575 Bytes

Contents

module CurrentAttributes::Base
  extend ActiveSupport::Concern

  included do
    attribute :user, :team, :membership, :ability, :context

    resets do
      Time.zone = nil
    end
  end

  def user=(user)
    super

    if user
      Time.zone = user.time_zone
      self.ability = Ability.new(user)
    else
      Time.zone = nil
      self.ability = nil
    end

    update_membership
  end

  def team=(team)
    super
    update_membership
  end

  def update_membership
    self.membership = if user && team
      user.memberships.where(team: team)
    end
  end
end

Version data entries

194 entries across 194 versions & 1 rubygems

Version Path
bullet_train-1.7.18 app/models/concerns/current_attributes/base.rb
bullet_train-1.7.17 app/models/concerns/current_attributes/base.rb
bullet_train-1.7.16 app/models/concerns/current_attributes/base.rb
bullet_train-1.7.15 app/models/concerns/current_attributes/base.rb
bullet_train-1.7.14 app/models/concerns/current_attributes/base.rb
bullet_train-1.7.13 app/models/concerns/current_attributes/base.rb
bullet_train-1.7.12 app/models/concerns/current_attributes/base.rb
bullet_train-1.7.11 app/models/concerns/current_attributes/base.rb
bullet_train-1.7.10 app/models/concerns/current_attributes/base.rb
bullet_train-1.7.9 app/models/concerns/current_attributes/base.rb
bullet_train-1.7.3 app/models/concerns/current_attributes/base.rb
bullet_train-1.7.2 app/models/concerns/current_attributes/base.rb
bullet_train-1.7.1 app/models/concerns/current_attributes/base.rb
bullet_train-1.7.0 app/models/concerns/current_attributes/base.rb
bullet_train-1.6.38 app/models/concerns/current_attributes/base.rb
bullet_train-1.6.37 app/models/concerns/current_attributes/base.rb
bullet_train-1.6.36 app/models/concerns/current_attributes/base.rb
bullet_train-1.6.35 app/models/concerns/current_attributes/base.rb
bullet_train-1.6.34 app/models/concerns/current_attributes/base.rb
bullet_train-1.6.33 app/models/concerns/current_attributes/base.rb