Module: Concerns::WinewooUserMixin

Extended by:
ActiveSupport::Concern
Included in:
User
Defined in:
app/models/concerns/winewoo_user_mixin.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.send_reset_password_instructions(attributes = {}, current_user_agent) ⇒ Object

Attempt to find a user by its email. If a record is found, send new password instructions to it. If user is not found, returns a new user with an email not found error. Attributes must contain the user’s email



80
81
82
83
84
85
86
# File 'app/models/concerns/winewoo_user_mixin.rb', line 80

def self.send_reset_password_instructions(attributes={}, current_user_agent)
  recoverable = find_or_initialize_with_errors(reset_password_keys, attributes, :not_found)
  recoverable.current_device_os = current_user_agent.device_os
  recoverable.save
  recoverable.send_reset_password_instructions if recoverable.persisted?
  recoverable
end

Instance Method Details

#add_wine_to_history(vintage, city, reco_id) ⇒ Object



57
58
59
60
61
62
63
# File 'app/models/concerns/winewoo_user_mixin.rb', line 57

def add_wine_to_history(vintage, city, reco_id)
  self.history_entries.create(city: city,
                              wine_id: vintage.wine.id,
                              vintage_id: vintage.id,
                              reco_id: reco_id)
  self.save
end

#authenticated?Boolean

Returns:

  • (Boolean)


71
72
73
# File 'app/models/concerns/winewoo_user_mixin.rb', line 71

def authenticated?
  self.status == :authenticated
end

#guest?Boolean

Returns:

  • (Boolean)


66
67
68
# File 'app/models/concerns/winewoo_user_mixin.rb', line 66

def guest?
  self.status == :guest
end

#save_for_interpro(interpro) ⇒ Object



45
46
47
48
# File 'app/models/concerns/winewoo_user_mixin.rb', line 45

def save_for_interpro(interpro)
  self.viewed_interpro_ids |= [interpro.id] if interpro
  self.save
end

#save_for_producer(producer) ⇒ Object



51
52
53
54
# File 'app/models/concerns/winewoo_user_mixin.rb', line 51

def save_for_producer(producer)
  self.viewed_producer_ids |= [producer.id] if producer
  self.save
end