Module: CurrentAttributes::Base

Extended by:
ActiveSupport::Concern
Defined in:
app/models/concerns/current_attributes/base.rb

Instance Method Summary collapse

Instance Method Details

#team=(team) ⇒ Object



26
27
28
29
# File 'app/models/concerns/current_attributes/base.rb', line 26

def team=(team)
  super
  update_membership
end

#update_membershipObject



31
32
33
34
35
# File 'app/models/concerns/current_attributes/base.rb', line 31

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

#user=(user) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/models/concerns/current_attributes/base.rb', line 12

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