Sha256: 1c5c0b7da3d0be0e410fbefd14fc049f320cbde308a6e4e767a013ea01a55506

Contents?: true

Size: 1.27 KB

Versions: 1

Compression:

Stored size: 1.27 KB

Contents

#
# ActiveFacts Compositions, Staging Compositor.
#
#       Computes a Staging schema for Data Vault.
#
# Copyright (c) 2016 Graeme Port. Read the LICENSE file.
#
require "activefacts/compositions/relational"

module ActiveFacts
  module Compositions
    class Staging < Relational
    public
      def self.options
        {
          stgname: ['String', "Suffix or pattern for naming staging tables. Include a + to insert the name. Default 'STG'"],
        }
      end

      def initialize constellation, name, options = {}
        # Extract recognised options:
        @option_stg_name = options.delete('stgname') || 'STG'
        @option_stg_name.sub!(/^/,'+ ') unless @option_stg_name =~ /\+/

        super constellation, name, options

      end

      def inject_all_datetime_recordsource
        composites = @composition.all_composite.to_a
        return if composites.empty?

        trace :staging, "Injecting load datetime and record source" do
          @composition.all_composite.each do |composite|
            inject_datetime_recordsource composite.mapping
            composite.mapping.re_rank
          end
        end
      end

      def devolve_all
        # Rename composites with STG prefix
        rename_parents
      end
    end

    publish_compositor(Staging)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
activefacts-compositions-1.9.9 lib/activefacts/compositions/staging.rb