Class: ActiveReporting::DimensionFilter

Inherits:
Object
  • Object
show all
Defined in:
lib/active_reporting/dimension_filter.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, type = :scope, body = nil) ⇒ DimensionFilter

Returns a new instance of DimensionFilter.



24
25
26
27
28
# File 'lib/active_reporting/dimension_filter.rb', line 24

def initialize(name, type = :scope, body = nil)
  @name = name.to_sym
  @type = type.to_sym
  @body = body
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



3
4
5
# File 'lib/active_reporting/dimension_filter.rb', line 3

def body
  @body
end

#typeObject (readonly)

Returns the value of attribute type.



3
4
5
# File 'lib/active_reporting/dimension_filter.rb', line 3

def type
  @type
end

Class Method Details

.build(name, lambda_or_type) ⇒ ActiveReporting::DimensionFilter

Factory for creating a new DimensionFilter

Determines the type based on if passed in a callable object or a symbol

Parameters:

  • name (Symbol)
  • lambda_or_type (Symbol, Lambda)

Returns:



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/active_reporting/dimension_filter.rb', line 12

def self.build(name, lambda_or_type)
  body = nil
  type = lambda_or_type

  if lambda_or_type.respond_to?(:call)
    body = lambda_or_type
    type = :lambda
  end

  new(name, type, body)
end