Sha256: d3c97ba0ad844bc35c0a590aabec2ce9ce2558ff1aeeb2dbf338f8a7a0a64212

Contents?: true

Size: 1.72 KB

Versions: 28

Compression:

Stored size: 1.72 KB

Contents

# frozen_string_literal: true
module Blacklight::Configurable
  extend ActiveSupport::Concern

  included do
    helper_method :blacklight_config if respond_to? :helper_method
  end

  #instance methods for blacklight_config, so get a deep copy of the class-level config
  def blacklight_config
    @blacklight_config ||= self.class.blacklight_config.deep_copy
  end
  attr_writer :blacklight_config

  class_methods do
    def copy_blacklight_config_from(other_class)
      self.blacklight_config = other_class.blacklight_config.inheritable_copy(self)
    end

    # lazy load a deep_copy of superclass if present, else
    # a default_configuration, which will be legacy load or new empty config.
    # note the @blacklight_config variable is a ruby 'instance method on class
    # object' that won't be automatically available to subclasses, that's why
    # we lazy load to 'inherit' how we want.
    def blacklight_config
      @blacklight_config ||= if superclass.respond_to?(:blacklight_config)
                               superclass.blacklight_config.build(self)
                             else
                               default_configuration
                             end
    end
    attr_writer :blacklight_config

    #simply a convenience method for blacklight_config.configure
    def configure_blacklight(*args, &block)
      blacklight_config.configure(*args, &block)
    end

    ##
    # The default configuration object
    def default_configuration
      Blacklight::Configurable.default_configuration.inheritable_copy(self)
    end
  end

  def self.default_configuration
    @default_configuration ||= Blacklight::Configuration.new
  end

  def self.default_configuration= config
    @default_configuration = config
  end
end

Version data entries

28 entries across 28 versions & 2 rubygems

Version Path
blacklight-7.40.0 app/models/concerns/blacklight/configurable.rb
blacklight-7.39.0 app/models/concerns/blacklight/configurable.rb
blacklight-7.38.0 app/models/concerns/blacklight/configurable.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/blacklight-7.37.0/app/models/concerns/blacklight/configurable.rb
blacklight-7.37.0 app/models/concerns/blacklight/configurable.rb
blacklight-7.36.2 app/models/concerns/blacklight/configurable.rb
blacklight-7.36.1 app/models/concerns/blacklight/configurable.rb
blacklight-7.36.0 app/models/concerns/blacklight/configurable.rb
blacklight-7.35.0 app/models/concerns/blacklight/configurable.rb
blacklight-7.34.0 app/models/concerns/blacklight/configurable.rb
blacklight-7.33.1 app/models/concerns/blacklight/configurable.rb
blacklight-7.33.0 app/models/concerns/blacklight/configurable.rb
blacklight-7.32.0 app/models/concerns/blacklight/configurable.rb
blacklight-7.31.0 app/models/concerns/blacklight/configurable.rb
blacklight-7.30.0 app/models/concerns/blacklight/configurable.rb
blacklight-7.29.0 app/models/concerns/blacklight/configurable.rb
blacklight-7.28.0 app/models/concerns/blacklight/configurable.rb
blacklight-7.27.1 app/models/concerns/blacklight/configurable.rb
blacklight-7.27.0 app/models/concerns/blacklight/configurable.rb
blacklight-7.26.1 app/models/concerns/blacklight/configurable.rb