Class: Blacklight::Configuration::Context
- Inherits:
-
Object
- Object
- Blacklight::Configuration::Context
- Defined in:
- lib/blacklight/configuration/context.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
Instance Method Summary collapse
- #evaluate_configuration_conditional(proc_helper_or_boolean, *args_for_procs_and_methods) ⇒ Object
-
#evaluate_if_unless_configuration(config, *args) ⇒ Boolean
Evaluate conditionals for a configuration with if/unless attributes.
-
#initialize(context) ⇒ Context
constructor
A new instance of Context.
Constructor Details
#initialize(context) ⇒ Context
Returns a new instance of Context.
7 8 9 |
# File 'lib/blacklight/configuration/context.rb', line 7 def initialize(context) @context = context end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
5 6 7 |
# File 'lib/blacklight/configuration/context.rb', line 5 def context @context end |
Instance Method Details
#evaluate_configuration_conditional(proc_helper_or_boolean, *args_for_procs_and_methods) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/blacklight/configuration/context.rb', line 30 def evaluate_configuration_conditional(proc_helper_or_boolean, *args_for_procs_and_methods) case proc_helper_or_boolean when Symbol arity = context.method(proc_helper_or_boolean).arity if arity.zero? context.send(proc_helper_or_boolean) else context.send(proc_helper_or_boolean, *args_for_procs_and_methods) end when Proc proc_helper_or_boolean.call context, *args_for_procs_and_methods else proc_helper_or_boolean end end |
#evaluate_if_unless_configuration(config, *args) ⇒ Boolean
Evaluate conditionals for a configuration with if/unless attributes
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/blacklight/configuration/context.rb', line 16 def evaluate_if_unless_configuration(config, *args) return config if config == true or config == false if_value = !config.respond_to?(:if) || config.if.nil? || evaluate_configuration_conditional(config.if, config, *args) unless_value = !config.respond_to?(:unless) || config.unless.nil? || !evaluate_configuration_conditional(config.unless, config, *args) if_value && unless_value end |