<commit_before>require 'rolify/railtie' if defined?(Rails)
require 'rolify/utils'
require 'rolify/role'
require 'rolify/configure'
require 'rolify/dynamic'
require 'rolify/resource'
require 'rolify/adapters/base'

module Rolify
  extend Configure

  attr_accessor :role_cname, :adapter

  def rolify(options = { :role_cname => 'Role' })
    include Role
    extend Dynamic if Rolify.dynamic_shortcuts
    
    rolify_options = { :class_name => options[:role_cname].camelize }
    rolify_options.merge!({ :join_table => "#{self.to_s.tableize}_#{options[:role_cname].tableize}" }) if Rolify.orm == "active_record"
    has_and_belongs_to_many :roles, rolify_options

    self.adapter = Rolify::Adapter::Base.create("role_adapter", options[:role_cname], self.name)
    self.role_cname = options[:role_cname]
    
    load_dynamic_methods if Rolify.dynamic_shortcuts
  end

  def resourcify(options = { :role_cname => 'Role' })
    include Resource
    
    resourcify_options = { :class_name => options[:role_cname].camelize, :as => :resource }
    has_many :roles, resourcify_options
    
    self.adapter = Rolify::Adapter::Base.create("resource_adapter", options[:role_cname], self.name)
    self.role_cname = options[:role_cname]
  end
  
  def scopify
    require "rolify/adapters/#{Rolify.orm}/scopes.rb"
  end
  
  def role_class
    self.role_cname.constantize
  end
end<commit_msg>Don't require :role_cname argument for rolify options<commit_after>require 'rolify/railtie' if defined?(Rails)
require 'rolify/utils'
require 'rolify/role'
require 'rolify/configure'
require 'rolify/dynamic'
require 'rolify/resource'
require 'rolify/adapters/base'

module Rolify
  extend Configure

  attr_accessor :role_cname, :adapter

  def rolify(options = {})
    include Role
    extend Dynamic if Rolify.dynamic_shortcuts
    
    options.reverse_merge!({:role_cname => 'Role'})

    rolify_options = { :class_name => options[:role_cname].camelize }
    rolify_options.merge!({ :join_table => "#{self.to_s.tableize}_#{options[:role_cname].tableize}" }) if Rolify.orm == "active_record"
    has_and_belongs_to_many :roles, rolify_options

    self.adapter = Rolify::Adapter::Base.create("role_adapter", options[:role_cname], self.name)
    self.role_cname = options[:role_cname]
    
    load_dynamic_methods if Rolify.dynamic_shortcuts
  end

  def resourcify(options = { :role_cname => 'Role' })
    include Resource
    
    resourcify_options = { :class_name => options[:role_cname].camelize, :as => :resource }
    has_many :roles, resourcify_options
    
    self.adapter = Rolify::Adapter::Base.create("resource_adapter", options[:role_cname], self.name)
    self.role_cname = options[:role_cname]
  end
  
  def scopify
    require "rolify/adapters/#{Rolify.orm}/scopes.rb"
  end
  
  def role_class
    self.role_cname.constantize
  end
end
{'fraction_non_alphanumeric': 0.11963406052076003, 'fraction_numerical': 0.0, 'mean_word_length': 4.50968992248062, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '2168892', 'n_tokens_mistral': 1003, 'n_tokens_neox': 981, 'n_words': 177}