Module ActiveWarehouse::SlowlyChangingDimension::ClassMethods
In: lib/active_warehouse/dimension/slowly_changing_dimension.rb

Methods

Included Modules

InstanceMethods

External Aliases

find_every -> find_every_with_older
calculate -> calculate_with_older
validate_find_options -> core_validate_find_options

Public Instance methods

Indicate that the dimension is a Type 2 Slowly Changing Dimension (SDC).

A word of warning:

The expiration_date field must never be null. For the current effective record use the maximum date allowed. This is necessary because the find query used when :valid_on is specified is implemented using a between clause.

Options:

  • :identifier:
  • :lastest_version: Define the attribute name which represents the latest version flag
  • :effective_date: Define the attribute name which represents the effective date column
  • :expiration_date: Define the attribute name which represents the expiration date column

[Source]

    # File lib/active_warehouse/dimension/slowly_changing_dimension.rb, line 37
37:       def acts_as_slowly_changing_dimension(options = {})
38:         unless slowly_changing_dimension? # don't let AR call this twice
39:           cattr_accessor :identifier
40:           cattr_accessor :latest_version_attribute
41:           cattr_accessor :effective_date_attribute
42:           cattr_accessor :expiration_date_attribute
43:           self.identifier = options[:identifier] || :identifier
44:           self.latest_version_attribute = options[:with] || :latest_version
45:           self.effective_date_attribute = options[:effective_date_attribute] || :effective_date
46:           self.expiration_date_attribute = options[:expiration_date_attribute] || :expiration_date
47:           class << self
48:             alias_method :find_every_with_older,    :find_every
49:             alias_method :calculate_with_older,     :calculate
50:             alias_method :core_validate_find_options, :validate_find_options
51:             VALID_FIND_OPTIONS << :with_older
52:             VALID_FIND_OPTIONS << :valid_on
53:             VALID_FIND_OPTIONS << :valid_during
54:           end
55:         end
56:         include InstanceMethods
57:       end

Return true if this dimension is a slowly changing dimension

[Source]

    # File lib/active_warehouse/dimension/slowly_changing_dimension.rb, line 60
60:       def slowly_changing_dimension?
61:         self.included_modules.include?(InstanceMethods)
62:       end

[Validate]