Module: ActiveWarehouse::HierarchicalDimension::InstanceMethods

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

Overview

:nodoc

Instance Method Summary collapse

Instance Method Details

#childrenObject

Get the children for this node



89
90
91
92
93
94
# File 'lib/active_warehouse/dimension/hierarchical_dimension.rb', line 89

def children
  self.class.find(:all, 
    :select => "a.*",
    :joins => "a join #{self.class.bridge_class.table_name} b on a.id = b.#{self.class.parent_foreign_key}", 
    :conditions => ["b.#{self.class.child_foreign_key} = ? and b.#{self.class.levels_from_parent} = 1", self.id])
end

#parentObject

Get the parent for this node



81
82
83
84
85
86
# File 'lib/active_warehouse/dimension/hierarchical_dimension.rb', line 81

def parent
  self.class.find(:first, 
    :select => "a.*",
    :joins => "a join #{self.class.bridge_class.table_name} b on a.id = b.#{self.class.child_foreign_key}", 
    :conditions => ["b.#{self.class.parent_foreign_key} = ? and b.#{self.class.levels_from_parent} = 1", self.id])
end