lib/qme/map/map_reduce_builder.rb in quality-measure-engine-2.3.0 vs lib/qme/map/map_reduce_builder.rb in quality-measure-engine-2.4.0

- old
+ new

@@ -9,19 +9,31 @@ attr_reader :id, :params # Utility class used to supply a binding to Erb class Context < OpenStruct # Create a new context - # @param [Hash] vars a hash of parameter names (String) and values (Object). Each entry is added as an accessor of the new Context + # @param [Hash] vars a hash of parameter names (String) and values (Object). Each + # entry is added as an accessor of the new Context def initialize(db, vars) - super(vars) + super(Context.add_defaults(vars)) @db = db end # Get a binding that contains all the instance variables # @return [Binding] def get_binding binding + end + + # Add default parameter values if not specified + def self.add_defaults(vars) + if !vars.has_key?('enable_logging') + vars['enable_logging'] = false + end + if !vars.has_key?('enable_rationale') + vars['enable_rationale'] = false + end + vars end # Inserts any library code into the measure JS. JS library code is loaded from # three locations: the js directory of the quality-measure-engine project, the # js sub-directory of the current directory (e.g. measures/js), and the bundles \ No newline at end of file