Sha256: a0f4fdb39b6bd5334c1f0856df8a2c77b3f913226c64d178aca793079a8a78c9

Contents?: true

Size: 1.1 KB

Versions: 2

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true
require 'closure_tree'
require 'configurations'
require 'active_record_union'

require 'monarchy/tasks'
require 'monarchy/engine'

require 'monarchy/acts_as_user'
require 'monarchy/acts_as_role'
require 'monarchy/acts_as_member'
require 'monarchy/acts_as_resource'
require 'monarchy/acts_as_hierarchy'

module Monarchy
  cattr_accessor :resource_classes

  def self.resource_classes
    @resource_classes ||= []
  end

  include Configurations

  configuration_defaults do |config|
    config.member_class_name = 'Monarchy::Member'
    config.role_class_name = 'Monarchy::Role'
    config.member_force_revoke = false
  end

  not_configured do |prop|
    raise NoMethodError, "Monarchy requires a #{prop} to be configured"
  end

  def self.member_class
    Monarchy.configuration.member_class_name.safe_constantize
  end

  def self.role_class
    Monarchy.configuration.role_class_name.safe_constantize
  end

  def self.user_class
    klass = Monarchy.configuration.user_class_name.safe_constantize
    klass ? klass : raise(ArgumentError, 'User class has to be initialized or exist!')
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
monarchy-1.1.5 lib/monarchy.rb
monarchy-1.1.4 lib/monarchy.rb