Class: Atrium::Configuration
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Atrium::Configuration
- Defined in:
- app/models/atrium/configuration.rb
Overview
This class is intended to be a decorator for the Blacklight::Configuration, yet could stand alone without Blacklight.
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#initialize(default_configuration) {|_self| ... } ⇒ Configuration
constructor
A new instance of Configuration.
- #label_for_facet(facet_name) ⇒ Object
- #query_param_beautifier(context, query_params) ⇒ Object
- #query_param_beautifier=(callable) ⇒ Object
Constructor Details
#initialize(default_configuration) {|_self| ... } ⇒ Configuration
Returns a new instance of Configuration.
5 6 7 8 |
# File 'app/models/atrium/configuration.rb', line 5 def initialize(default_configuration) super(default_configuration) yield(self) if block_given? end |
Instance Attribute Details
#application_name ⇒ Object
11 12 13 14 15 |
# File 'app/models/atrium/configuration.rb', line 11 def application_name @application_name || super rescue NoMethodError '' end |
#saved_items_class ⇒ Object
33 34 35 36 37 38 39 |
# File 'app/models/atrium/configuration.rb', line 33 def saved_items_class if @saved_items_class.respond_to?(:constantize) @saved_items_class.constantize else raise(Atrium::ConfigurationNotSet, 'Atrium.config.saved_items_class') end end |
#saved_search_class ⇒ Object
24 25 26 27 28 29 30 |
# File 'app/models/atrium/configuration.rb', line 24 def saved_search_class if @saved_search_class.respond_to?(:constantize) @saved_search_class.constantize else raise(Atrium::ConfigurationNotSet, 'Atrium.config.saved_search_class') end end |
Instance Method Details
#label_for_facet(facet_name) ⇒ Object
17 18 19 20 21 |
# File 'app/models/atrium/configuration.rb', line 17 def label_for_facet(facet_name) facet_fields[facet_name].label rescue NoMethodError, NameError facet_name end |
#query_param_beautifier(context, query_params) ⇒ Object
57 58 59 60 61 62 63 |
# File 'app/models/atrium/configuration.rb', line 57 def query_param_beautifier(context,query_params) if defined?(@query_param_beautifier) && @query_param_beautifier @query_param_beautifier.call(context,query_params) else query_params.inspect end end |
#query_param_beautifier=(callable) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'app/models/atrium/configuration.rb', line 41 def query_param_beautifier=(callable) if callable.nil? @query_param_beautifier = nil return callable end if ! callable.respond_to?(:call) = "Expected Atrium.query_param_beautifier to respond to :call" raise Atrium::ConfigurationExpectation, end if callable.arity != 2 = "Expected Atrium.query_param_beautifier to require 2 args" raise Atrium::ConfigurationExpectation, end @query_param_beautifier = callable end |