Class: Profile

Inherits:
ApplicationRecord
  • Object
show all
Defined in:
app/models/profile.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#birth_dateObject

Returns the value of attribute birth_date.



21
22
23
# File 'app/models/profile.rb', line 21

def birth_date
  @birth_date
end

Instance Method Details

#set_date_of_birthTime

ユーザの誕生日を設定します。

Returns:

  • (Time)


69
70
71
72
73
# File 'app/models/profile.rb', line 69

def set_date_of_birth
  self.date_of_birth = Time.zone.parse(birth_date) if birth_date
rescue ArgumentError
  nil
end

#set_expired_atTime

ユーザの有効期限を設定します。

Returns:

  • (Time)


59
60
61
62
63
64
65
# File 'app/models/profile.rb', line 59

def set_expired_at
  if expired_at.blank?
    if user_group.valid_period_for_new_user > 0
      self.expired_at = user_group.valid_period_for_new_user.days.from_now.end_of_day
    end
  end
end

#set_role_and_agentvoid

This method returns an undefined value.

既定のユーザ権限を設定します。



52
53
54
55
# File 'app/models/profile.rb', line 52

def set_role_and_agent
  self.required_role = Role.find_by(name: 'Librarian') unless required_role
  self.locale = I18n.default_locale.to_s unless locale
end