Module: ActiveWarehouse::HierarchicalDimension::ClassMethods

Defined in:
lib/active_warehouse/dimension/hierarchical_dimension.rb

Overview

:nodoc

Instance Method Summary collapse

Instance Method Details

#acts_as_hierarchy_dimensionObject Also known as: acts_as_hierarchical_dimension

Indicates that a dimension is a variable-depth hierarchy.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/active_warehouse/dimension/hierarchical_dimension.rb', line 11

def acts_as_hierarchy_dimension
  unless hierarchical_dimension?
     class << self
       # Get the bridge class for this dimension
       def bridge_class
         unless @bridge_class
           unless Object.const_defined?(bridge_class_name.to_sym)
             Object.const_set(bridge_class_name.to_sym, Class.new(ActiveWarehouse::Bridge))
           end
           @bridge_class = Object.const_get(bridge_class_name.to_sym)
         end
         @bridge_class
       end

       # Get the bridge class name for this hierarchical dimension
       def bridge_class_name
         name.gsub(/Dimension$/, '') + 'HierarchyBridge'
       end
     end
  end
  include InstanceMethods
end

#hierarchical_dimension?Boolean

Return true if this is a hierarchical dimension



36
37
38
# File 'lib/active_warehouse/dimension/hierarchical_dimension.rb', line 36

def hierarchical_dimension?
  self.included_modules.include?(InstanceMethods)
end