Sha256: d372274bd9f3ee0f25b907d4147a64b213ec9fb90e7ee7525a70e025fe1fb026
Contents?: true
Size: 1.7 KB
Versions: 21
Compression:
Stored size: 1.7 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(...) blacklight_config.configure(...) 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
21 entries across 21 versions & 2 rubygems