<commit_before>class User < ApplicationRecord
  # Include default devise modules. Others available are:
  # :omniauthable
  devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable,
         :validatable, :confirmable, :lockable, :timeoutable

  ROLES = { 0 => 'guest', 1 => 'organizer', 2 => 'member', 3 => 'volunteer' }

  alias_attribute :name, :username

  has_one :profile
  has_many :addresses
  has_many :contacts, as: :resource

  validates :username, presence: true, uniqueness: { case_sensitive: false }

  # setter
  def role=(val)
    self[:role] = ROLES.key(val)
  end

  # getter
  def role
    ROLES[self[:role]]
  end

  ROLES.each do |id, name|
    define_method "#{name}?" do
      role == name
    end
  end
end<commit_msg>Changes in getter setter for User#role<commit_after>class User < ApplicationRecord
  # Include default devise modules. Others available are:
  # :omniauthable
  devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable,
         :validatable, :confirmable, :lockable, :timeoutable

  ROLES = { 0 => 'guest', 1 => 'organizer', 2 => 'member', 3 => 'volunteer' }

  alias_attribute :name, :username

  has_one :profile
  has_many :addresses
  has_many :contacts, as: :resource

  validates :username, presence: true, uniqueness: { case_sensitive: false }

  # setter
  def role=(val)
    super(ROLES.key(val))
  end

  # getter
  def role
    ROLES[super]
  end

  ROLES.each do |id, name|
    define_method "#{name}?" do
      role == name
    end
  end
end
{'fraction_non_alphanumeric': 0.11794871794871795, 'fraction_numerical': 0.005128205128205128, 'mean_word_length': 3.7883435582822087, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4181477', 'n_tokens_mistral': 543, 'n_tokens_neox': 514, 'n_words': 145}