Module: ActiveWarehouse::SlowlyChangingDimension

Included in:
Dimension
Defined in:
lib/active_warehouse/dimension/slowly_changing_dimension.rb

Overview

Implements Type 2 Slowly Changing Dimensions.

In a type 2 SCD, a new row is added each time a dimension entry requires an update. Three columns are required in the dimension table to support this:

  • latest_version - A boolean flag which indicates whether or not the row is the latest and current value

  • effective_date - A start date for when this row takes effect

  • expiration_date - An end date for when this row expires

This module will override finder behavior in several ways. If used in a normal fashion, the find method will return the match row or rows with the latest_version flag set to true. You can also call the finder with the :valid_on option set indicating that you want the row that is valid on the given date.

You can completely override the modified finder behavior using the :with_older option (set to true). You must include this option if you want to search for records which are not current (for example, using the find(id) version of the finder methods).

Defined Under Namespace

Modules: ClassMethods, InstanceMethods

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object

:nodoc:



19
20
21
# File 'lib/active_warehouse/dimension/slowly_changing_dimension.rb', line 19

def self.included(base) # :nodoc:
  base.extend ClassMethods
end