Sha256: 20165b577815d20262cfb4e8ba895984227d0a13b52d28165404f894d80ce5a9

Contents?: true

Size: 983 Bytes

Versions: 5

Compression:

Stored size: 983 Bytes

Contents

class Prometeus < ApplicationRecord

  self.abstract_class = true

  has_one :user_card, as: :userable, dependent: :destroy
  has_one :avatar, as: :imageable, dependent: :destroy

  after_create :add_user_card

  validates :name, :length => {:maximum => 64, :message => 'максимальная длина имени 64 символа'}

  scope :not_me, -> (user_card_id) {joins(:user_card).where.not('user_cards.id = ?', user_card_id)}

  def add_user_card
    self.create_user_card({password: 'mussypussy', access_level: self.class.name.underscore})
  end

  def my_nicknames
    self.user_card.my_nicknames
  end

  def my_nickname
    self.user_card.my_nickname
  end

  def my_emails
    self.user_card.my_emails
  end

  def my_email
    self.user_card.my_email
  end

  def my_phones
    self.user_card.my_phones
  end

  def my_phone
    self.user_card.my_phone
  end

  def whoami
    self.class.name.underscore
  end

  def isi _alias
    self.whoami == _alias
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
digital_heroes_startkit-0.1.1.4 app/models/prometeus.rb
digital_heroes_startkit-0.1.1.3 app/models/prometeus.rb
digital_heroes_startkit-0.1.1.2 app/models/prometeus.rb
digital_heroes_startkit-0.1.1.1 app/models/prometeus.rb
digital_heroes_startkit-0.1.1 app/models/prometeus.rb