Class: MDQuery::DSL::DimensionSegmentDSL

Inherits:
Object
  • Object
show all
Defined in:
lib/mdquery/dsl.rb

Overview

DSL for describing a DimensionSegment

Instance Method Summary collapse

Instance Method Details

#cast(c) ⇒ Object

define a cast to convert values into the desired datatype

  • c a keyword key for the casts in MDQuery::Model::Casts



46
47
48
49
# File 'lib/mdquery/dsl.rb', line 46

def cast(c)
  raise "unknown cast: #{c.inspect}" if !MDQuery::Model::CASTS.keys.include?(c)
  @value_cast = c
end

#extract_dimension(q) ⇒ Object

extract DimensionValues from data for this segment. exclusive of fix_dimension

  • q SQL select string fragment for the dimension value



17
18
19
# File 'lib/mdquery/dsl.rb', line 17

def extract_dimension(q)
  @extract_dimension_query=q
end

#fix_dimension(v) ⇒ Object

fix the Dimension value for this segment. exclusive of extract_dimension

  • v the Dimension value for this segment



11
12
13
# File 'lib/mdquery/dsl.rb', line 11

def fix_dimension(v)
  @fixed_dimension_value=v
end

#label(&proc) ⇒ Object

set a Proc to be used to convert Dimension values into labels. Optional

  • proc a Proc of a single parameter which will be called to convert Dimension values

into labels



39
40
41
42
# File 'lib/mdquery/dsl.rb', line 39

def label(&proc)
  raise "no block!" if !proc
  @label_proc = proc
end

#modify(measure, &proc) ⇒ Object

set a Proc to be used to modify the measure-value in any query using this segment

  • measure a keyword describing the Measure

  • proc a Proc of a single parameter which will be used to transform the measure value



54
55
56
57
# File 'lib/mdquery/dsl.rb', line 54

def modify(measure, &proc)
  raise "no block!" if !proc
  @measure_modifiers[measure] = proc
end

#narrow(&proc) ⇒ Object

Narrow the datasource to extract this segment. Optional

  • proc a Proc of a single parameter, an ActiveRecord Scope to be narrowed



23
24
25
26
# File 'lib/mdquery/dsl.rb', line 23

def narrow(&proc)
  raise "no block!" if !proc
  @narrow_proc = proc
end

#values(&proc) ⇒ Object

Define an ordered list of all possible Dimension Values for the segment. Optional

  • proc a Proc of a single parameter, an ActiveRecord Scope which can be used

to query for the values



31
32
33
34
# File 'lib/mdquery/dsl.rb', line 31

def values(&proc)
  raise "no block!" if !proc
  @values_proc = proc
end