Module: Octo::Segmentation::Helpers
- Defined in:
- lib/octocore-mongo/segment.rb
Class Method Summary collapse
-
.choices_for_dimensions(dimension, enterprise_id) ⇒ Object
Helper method to return valid choices for a given dimension.
-
.dimensions_as_choice ⇒ Array<Hash{Symbol => String }>
Helper method for returning dimensions as choice to be used in the UX.
-
.logic_operators_as_choice ⇒ Object
Returns logic operatos as a choice for operating between dimensions.
-
.operators_as_choice(dimension = nil) ⇒ Array<Hash{Symbol => String }>
Helper method for returning operators as a hash to be used in UX.
Class Method Details
.choices_for_dimensions(dimension, enterprise_id) ⇒ Object
Helper method to return valid choices for a given dimension. It tries
to find the values from db first. In case, there is nothing, it
shows some default values, so the dashboard does not look totally
blank.
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/octocore-mongo/segment.rb', line 49 def choices_for_dimensions(dimension, enterprise_id) args = { enterprise_id: enterprise_id, dimension: dimension } res = Octo::DimensionChoice.where(args) choices = Array.new if res.count > 0 choices = res.collect do |r| r.column end elsif dimension_choice.has_key?(dimension) func = dimension_choice[dimension] choices = self.send(func, enterprise_id) end mapping_as_choice Hash[Array.new(choices.count) { |i| i }.zip(choices)] end |
.dimensions_as_choice ⇒ Array<Hash{Symbol => String }>
Helper method for returning dimensions as choice to be used in the UX
32 33 34 |
# File 'lib/octocore-mongo/segment.rb', line 32 def dimensions_as_choice mapping_as_choice dimension_text end |
.logic_operators_as_choice ⇒ Object
Returns logic operatos as a choice for operating between dimensions
37 38 39 |
# File 'lib/octocore-mongo/segment.rb', line 37 def logic_operators_as_choice mapping_as_choice logic_text end |