Sha256: 89167843b2c04e64a3dd38b6d7263cb97c1405c8d2ae35cbaa68c8feb1ea85e1

Contents?: true

Size: 903 Bytes

Versions: 10

Compression:

Stored size: 903 Bytes

Contents

# frozen_string_literal: true

module BaseEditingBootstrap
  module BaseModel
    extend ActiveSupport::Concern

    included do
      include IsValidated
      include ActionTranslation
      delegate :ransackable_attributes, :ransackable_associations, to: :@class
    end

    class_methods do
      def ransackable_attributes(auth_object = nil)
        if auth_object
          Pundit.policy(auth_object, self.new).permitted_attributes_for_ransack.map(&:to_s)
        else
          Pundit.policy(User.new, self.new).permitted_attributes_for_ransack.map(&:to_s)
        end
      end

      def ransackable_associations(auth_object = nil)
        if auth_object
          Pundit.policy(auth_object, self.new).permitted_associations_for_ransack.map(&:to_s)
        else
          Pundit.policy(User.new, self.new).permitted_associations_for_ransack.map(&:to_s)
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
base_editing_bootstrap-1.4.0 lib/base_editing_bootstrap/base_model.rb
base_editing_bootstrap-1.3.2 lib/base_editing_bootstrap/base_model.rb
base_editing_bootstrap-1.3.1 lib/base_editing_bootstrap/base_model.rb
base_editing_bootstrap-1.3.0 lib/base_editing_bootstrap/base_model.rb
base_editing_bootstrap-1.2.0 lib/base_editing_bootstrap/base_model.rb
base_editing_bootstrap-1.1.0 lib/base_editing_bootstrap/base_model.rb
base_editing_bootstrap-1.0.0 lib/base_editing_bootstrap/base_model.rb
base_editing_bootstrap-0.16.1 lib/base_editing_bootstrap/base_model.rb
base_editing_bootstrap-0.16.0 lib/base_editing_bootstrap/base_model.rb
base_editing_bootstrap-0.15.0 lib/base_editing_bootstrap/base_model.rb