Sha256: e27a76764dd32a89dcdbe670e60f093c6b0e0599de128520f32e72d5c6ec48b3
Contents?: true
Size: 791 Bytes
Versions: 5
Compression:
Stored size: 791 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}" after_create :default_inherited_role 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
5 entries across 5 versions & 1 rubygems