Sha256: a9f266964cb7a20db25c854f2b0a12fe0a58714e193c9e9ccb7f100690fba80b

Contents?: true

Size: 565 Bytes

Versions: 18

Compression:

Stored size: 565 Bytes

Contents

module CurrentAttributes::Base
  extend ActiveSupport::Concern

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

    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

18 entries across 18 versions & 1 rubygems

Version Path
bullet_train-1.0.47 app/models/concerns/current_attributes/base.rb
bullet_train-1.0.46 app/models/concerns/current_attributes/base.rb
bullet_train-1.0.45 app/models/concerns/current_attributes/base.rb
bullet_train-1.0.42 app/models/concerns/current_attributes/base.rb
bullet_train-1.0.41 app/models/concerns/current_attributes/base.rb
bullet_train-1.0.40 app/models/concerns/current_attributes/base.rb
bullet_train-1.0.39 app/models/concerns/current_attributes/base.rb
bullet_train-1.0.38 app/models/concerns/current_attributes/base.rb
bullet_train-1.0.37 app/models/concerns/current_attributes/base.rb
bullet_train-1.0.36 app/models/concerns/current_attributes/base.rb
bullet_train-1.0.35 app/models/concerns/current_attributes/base.rb
bullet_train-1.0.34 app/models/concerns/current_attributes/base.rb
bullet_train-1.0.33 app/models/concerns/current_attributes/base.rb
bullet_train-1.0.32 app/models/concerns/current_attributes/base.rb
bullet_train-1.0.31 app/models/concerns/current_attributes/base.rb
bullet_train-1.0.30 app/models/concerns/current_attributes/base.rb
bullet_train-1.0.29 app/models/concerns/current_attributes/base.rb
bullet_train-1.0.28 app/models/concerns/current_attributes/base.rb