Class: QME::MapReduce::Builder::Context
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- QME::MapReduce::Builder::Context
- Defined in:
- lib/qme/map/map_reduce_builder.rb
Overview
Utility class used to supply a binding to Erb
Class Method Summary collapse
-
.add_defaults(vars) ⇒ Object
Add default parameter values if not specified.
Instance Method Summary collapse
-
#get_binding ⇒ Binding
Get a binding that contains all the instance variables.
-
#init_js_frameworks ⇒ Object
Inserts any library code into the measure JS.
-
#initialize(db, vars) ⇒ Context
constructor
Create a new context entry is added as an accessor of the new Context.
Constructor Details
#initialize(db, vars) ⇒ Context
Create a new context entry is added as an accessor of the new Context
16 17 18 19 |
# File 'lib/qme/map/map_reduce_builder.rb', line 16 def initialize(db, vars) super(Context.add_defaults(vars)) @db = db end |
Class Method Details
.add_defaults(vars) ⇒ Object
Add default parameter values if not specified
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/qme/map/map_reduce_builder.rb', line 28 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 if !vars.has_key?('short_circuit') vars['short_circuit'] = false end vars end |
Instance Method Details
#get_binding ⇒ Binding
Get a binding that contains all the instance variables
23 24 25 |
# File 'lib/qme/map/map_reduce_builder.rb', line 23 def get_binding binding end |
#init_js_frameworks ⇒ Object
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 collection of the current database (used by the Rails Web application).
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/qme/map/map_reduce_builder.rb', line 45 def init_js_frameworks result = '' result << 'if (typeof(map)=="undefined") {' result << "\n" @db['bundles'].find.each do |bundle| (bundle['extensions'] || []).each do |ext| result << "#{ext}();\n" end end result << "}\n" result end |