Sha256: 43a742225d571d1ff69293750833231856ed1f32533198e1797bca3c14c5ad53

Contents?: true

Size: 1.52 KB

Versions: 5

Compression:

Stored size: 1.52 KB

Contents

# frozen_string_literal: true

module Spree::RansackableAttributes
  extend ActiveSupport::Concern
  included do
    class_attribute :allowed_ransackable_associations, default: []
    class_attribute :allowed_ransackable_attributes, default: []

    def self.whitelisted_ransackable_associations
      Spree::Deprecation.deprecation_warning(:whitelisted_ransackable_associations, 'use allowed_ransackable_associations instead')
      allowed_ransackable_associations
    end

    def self.whitelisted_ransackable_associations=(new_value)
      Spree::Deprecation.deprecation_warning(:whitelisted_ransackable_associations=, 'use allowed_ransackable_associations= instead')
      self.allowed_ransackable_associations = new_value
    end

    def self.whitelisted_ransackable_attributes
      Spree::Deprecation.deprecation_warning(:whitelisted_ransackable_attributes, 'use allowed_ransackable_attributes instead')
      allowed_ransackable_attributes
    end

    def self.whitelisted_ransackable_attributes=(new_value)
      Spree::Deprecation.deprecation_warning(:whitelisted_ransackable_attributes=, 'use allowed_ransackable_attributes= instead')
      self.allowed_ransackable_attributes = new_value
    end

    class_attribute :default_ransackable_attributes
    self.default_ransackable_attributes = %w[id]
  end

  class_methods do
    def ransackable_associations(*_args)
      allowed_ransackable_associations
    end

    def ransackable_attributes(*_args)
      default_ransackable_attributes | allowed_ransackable_attributes
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
solidus_core-3.3.4 app/models/concerns/spree/ransackable_attributes.rb
solidus_core-3.3.3 app/models/concerns/spree/ransackable_attributes.rb
solidus_core-3.3.2 app/models/concerns/spree/ransackable_attributes.rb
solidus_core-3.3.1 app/models/concerns/spree/ransackable_attributes.rb
solidus_core-3.3.0 app/models/concerns/spree/ransackable_attributes.rb