Sha256: fda8c2cd39e9ed809f9fabaf15df0f5671313bdab3960a033be052df2c74dcc2

Contents?: true

Size: 1.35 KB

Versions: 6

Compression:

Stored size: 1.35 KB

Contents

module Trailblazer
  class Activity
    # The idea with {:config} is to have a generic runtime store for feature fields
    # like {:wrap_static} but also for flags, e.g. `each: true` from the Each() macro.
    class Schema < Struct.new(:circuit, :outputs, :nodes, :config)
      # {:nodes} is passed directly from {compile_activity}. We need to store this data here.

      # @!method to_h()
      #   Returns a hash containing the schema's components.

      class Nodes < Hash
        # In Attributes we store data from Intermediate and Implementing compile-time.
        # This would be lost otherwise.
        Attributes = Struct.new(:id, :task, :data, :outputs)
      end

      # Builder for {Schema::Nodes} datastructure.
      #
      # A {Nodes} instance is a hash of Attributes, keyed by task. It turned out that
      # 90% of introspect lookups, we search for attributes for a particular *task*, not ID.
      # That's why in 0.16.0 we changed this structure.5
      #
      # Nodes{#<task> => #<Nodes::Attributes id= task= data= outputs=>}
      #
      # @private Please use {Introspect.Nodes} for querying nodes.
      def self.Nodes(nodes)
        Nodes[
          nodes.collect do |attrs|
            [
              attrs[1], # task
              Nodes::Attributes.new(*attrs).freeze
            ]
          end
        ].freeze
      end
    end # Schema
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
trailblazer-activity-0.17.0 lib/trailblazer/activity/schema.rb
trailblazer-activity-0.16.4 lib/trailblazer/activity/schema.rb
trailblazer-activity-0.16.3 lib/trailblazer/activity/schema.rb
trailblazer-activity-0.16.2 lib/trailblazer/activity/schema.rb
trailblazer-activity-0.16.1 lib/trailblazer/activity/schema.rb
trailblazer-activity-0.16.0 lib/trailblazer/activity/schema.rb