Sha256: 86a0349dbc6eb3383a37a220c9acae659ab28a2323f1803b60ea710c69b85883

Contents?: true

Size: 658 Bytes

Versions: 24

Compression:

Stored size: 658 Bytes

Contents

module Challah
  module UserAuthorizable
    extend ActiveSupport::Concern

    included do
      extend ClassMethods

      before_destroy :clear_authorizations_before_destroy
    end

    protected

    def authorizations
      return [] if new_record?
      self.class.authorization_model.where(user_id: self.id)
    end

    def clear_authorizations_before_destroy
      authorizations.destroy_all
    end

    module ClassMethods
      def authorizations_table_name
        @authorizations_table_name ||= authorization_model.table_name
      end

      def authorization_model
        @authorization_model ||= ::Authorization
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
challah-1.6.1 lib/challah/concerns/user/authorizable.rb
challah-1.6.0 lib/challah/concerns/user/authorizable.rb
challah-1.5.0 lib/challah/concerns/user/authorizable.rb
challah-1.4.2 lib/challah/concerns/user/authorizable.rb
challah-1.4.1 lib/challah/concerns/user/authorizable.rb
challah-1.4.0 lib/challah/concerns/user/authorizable.rb
challah-1.3.3 lib/challah/concerns/user/authorizable.rb
challah-1.3.2 lib/challah/concerns/user/authorizable.rb
challah-1.3.1 lib/challah/concerns/user/authorizable.rb
challah-1.3.0 lib/challah/concerns/user/authorizable.rb
challah-1.2.11 lib/challah/concerns/user/authorizable.rb
challah-1.2.10 lib/challah/concerns/user/authorizable.rb
challah-1.2.9 lib/challah/concerns/user/authorizable.rb
challah-1.2.8 lib/challah/concerns/user/authorizable.rb
challah-1.2.7 lib/challah/concerns/user/authorizable.rb
challah-1.2.6 lib/challah/concerns/user/authorizable.rb
challah-1.2.5 lib/challah/concerns/user/authorizable.rb
challah-1.2.5.pre lib/challah/concerns/user/authorizable.rb
challah-1.2.4 lib/challah/concerns/user/authorizable.rb
challah-1.2.3 lib/challah/concerns/user/authorizable.rb