Sha256: ce9c6c22fab2438dfaa8b23318088380d877786f39856b412f5b7c99245365b2
Contents?: true
Size: 889 Bytes
Versions: 2
Compression:
Stored size: 889 Bytes
Contents
# frozen_string_literal: true module Monarchy module ActsAsRole extend ActiveSupport::Concern module ClassMethods def acts_as_role self.table_name = 'monarchy_roles' has_many :members_roles, dependent: :destroy, class_name: 'Monarchy::MembersRole' has_many :members, through: :members_roles, class_name: "::#{Monarchy.member_class}" belongs_to :inherited_role, class_name: "::#{Monarchy.role_class}", optional: true after_create :default_inherited_role validates :name, presence: true validates :level, presence: true include Monarchy::ActsAsRole::InstanceMethods end end module InstanceMethods private def default_inherited_role update(inherited_role_id: id) unless inherited_role end end end end ActiveRecord::Base.send :include, Monarchy::ActsAsRole
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
monarchy-2.7.0 | lib/monarchy/acts_as_role.rb |
monarchy-2.6.1 | lib/monarchy/acts_as_role.rb |