Class: Marbu::Models::Misc
- Inherits:
-
Object
- Object
- Marbu::Models::Misc
- Defined in:
- lib/marbu/models/mrf/misc.rb
Constant Summary collapse
- VALUE =
:value
- DOCUMENT_OFFSET =
VALUE.to_s + "."
Instance Attribute Summary collapse
-
#database ⇒ Object
Returns the value of attribute database.
-
#document_offset ⇒ Object
Returns the value of attribute document_offset.
-
#filter_data ⇒ Object
if filter_data is true, a query will be created depending on the filter parameters in filter_model if filter_data is false, no query will generated this is necessary for multiple sequentiell map_reduces: some will work on already filtered data (so no filter needed) while others will grab data from other collections which need to be filtered first.
-
#input_collection ⇒ Object
Returns the value of attribute input_collection.
-
#output_collection ⇒ Object
Returns the value of attribute output_collection.
-
#output_operation ⇒ Object
Returns the value of attribute output_operation.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #blank? ⇒ Boolean
- #collection ⇒ Object
- #default_params ⇒ Object
-
#initialize(ext_params = {}) ⇒ Misc
constructor
A new instance of Misc.
- #present? ⇒ Boolean
- #serializable_hash ⇒ Object
Constructor Details
#initialize(ext_params = {}) ⇒ Misc
Returns a new instance of Misc.
15 16 17 18 19 20 21 22 23 |
# File 'lib/marbu/models/mrf/misc.rb', line 15 def initialize( ext_params = {} ) params = default_params.merge( ext_params.delete_if{|k,v|v.blank?} ) self.database = params[:database] self.input_collection = params[:input_collection] self.output_collection = params[:output_collection] self.output_operation = params[:output_operation] self.filter_data = params[:filter_data] end |
Instance Attribute Details
#database ⇒ Object
Returns the value of attribute database.
4 5 6 |
# File 'lib/marbu/models/mrf/misc.rb', line 4 def database @database end |
#document_offset ⇒ Object
Returns the value of attribute document_offset.
10 11 12 |
# File 'lib/marbu/models/mrf/misc.rb', line 10 def document_offset @document_offset end |
#filter_data ⇒ Object
if filter_data is true, a query will be created depending on the filter parameters in filter_model if filter_data is false, no query will generated this is necessary for multiple sequentiell map_reduces: some will work on already filtered data (so no filter needed) while others will grab data from other collections which need to be filtered first
9 10 11 |
# File 'lib/marbu/models/mrf/misc.rb', line 9 def filter_data @filter_data end |
#input_collection ⇒ Object
Returns the value of attribute input_collection.
4 5 6 |
# File 'lib/marbu/models/mrf/misc.rb', line 4 def input_collection @input_collection end |
#output_collection ⇒ Object
Returns the value of attribute output_collection.
4 5 6 |
# File 'lib/marbu/models/mrf/misc.rb', line 4 def output_collection @output_collection end |
#output_operation ⇒ Object
Returns the value of attribute output_operation.
4 5 6 |
# File 'lib/marbu/models/mrf/misc.rb', line 4 def output_operation @output_operation end |
#value ⇒ Object
Returns the value of attribute value.
10 11 12 |
# File 'lib/marbu/models/mrf/misc.rb', line 10 def value @value end |
Instance Method Details
#blank? ⇒ Boolean
46 47 48 |
# File 'lib/marbu/models/mrf/misc.rb', line 46 def blank? !present? end |
#collection ⇒ Object
60 61 62 |
# File 'lib/marbu/models/mrf/misc.rb', line 60 def collection Marbu.connection.db(database).collection(input_collection) end |
#default_params ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/marbu/models/mrf/misc.rb', line 25 def default_params { :value => VALUE, :document_offset => DOCUMENT_OFFSET, :filter_data => false, :output_operation => "replace" } end |
#present? ⇒ Boolean
42 43 44 |
# File 'lib/marbu/models/mrf/misc.rb', line 42 def present? database.present? || input_collection.present? || output_collection.present? end |
#serializable_hash ⇒ Object
50 51 52 53 54 55 56 57 58 |
# File 'lib/marbu/models/mrf/misc.rb', line 50 def serializable_hash { :database => database, :input_collection => input_collection, :output_collection => output_collection, :output_operation => output_operation, :filter_data => filter_data }.delete_if{|k,v|v.blank?} end |