<commit_before># == Schema Information
#
# Table name: roles
#
#  id         :integer          not null, primary key
#  name       :string(255)
#  created_at :datetime         not null
#  updated_at :datetime         not null
#

class Role < ActiveRecord::Base
  attr_accessible :name

  has_many :assignments
  has_many :grants

  has_many :users, :through => :assignments
  has_many :rights, :through => :grants

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

  scope :for, lambda { |resource, action|
                where("rights.operation = ? AND rights.resource = ?",
                      Right::OPERATION_MAPPINGS[action], resource
                )
              }

  # class methods for roles so we can access them fast
  # * Role.admin
  # * Role.viewer
  # * Role.reporter

  def self.admin
    where(name: 'Admin').first
  end

  def self.reporter
    where(name: 'Reporter').first
  end

  def self.viewer
    where(name: 'Viewer').first
  end
end
<commit_msg>Indentation fix<commit_after># == Schema Information
#
# Table name: roles
#
#  id         :integer          not null, primary key
#  name       :string(255)
#  created_at :datetime         not null
#  updated_at :datetime         not null
#

class Role < ActiveRecord::Base
  attr_accessible :name

  has_many :assignments
  has_many :grants

  has_many :users, :through => :assignments
  has_many :rights, :through => :grants

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

  scope :for, lambda { |resource, action|

  # class methods for roles so we can access them fast
  # * Role.admin
  # * Role.viewer
  # * Role.reporter

  def self.admin
    where(name: 'Admin').first
  end

  def self.reporter
    where(name: 'Reporter').first
  end

  def self.viewer
    where(name: 'Viewer').first
  end
    where("rights.operation = ? AND rights.resource = ?",
          Right::OPERATION_MAPPINGS[action], resource
    )
  }
end

{'fraction_non_alphanumeric': 0.10429447852760736, 'fraction_numerical': 0.003067484662576687, 'mean_word_length': 2.6647940074906367, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '4181467', 'n_tokens_mistral': 633, 'n_tokens_neox': 599, 'n_words': 171}