Sha256: 1e689b728a74a59590f357258241ebe4a0c8bec8a9bf3909e6d5a563011566d0

Contents?: true

Size: 1.37 KB

Versions: 20

Compression:

Stored size: 1.37 KB

Contents

module MCollective
  class Aggregate
    class Base
      attr_accessor :name, :result, :output_name, :action, :aggregate_format, :arguments

      def initialize(output_name, arguments, aggregate_format, action)
        @name = self.class.to_s
        @output_name = output_name

        # Any additional arguments passed in the ddl after the output field will
        # be stored in the arguments array which can be used in the function
        @arguments = arguments
        @aggregate_format = aggregate_format
        @action = action
        @result = {:value => nil, :type => nil, :output => output_name}

        startup_hook
      end

      ["startup_hook", "process_result"].each do |method|
        define_method method do
          raise "'#{method}' method of function class #{@name} has not yet been implemented"
        end
      end

      # Stops execution of the function and returns a specific ResultObject,
      # aggregate functions will most likely override this but this is the simplest
      # case so we might as well default to that
      def summarize
        raise "Result type is not set while trying to summarize aggregate function results" unless @result[:type]

        result_class(@result[:type]).new(@result, @aggregate_format, @action)
      end

      def result_class(type)
        Result.const_get("#{type.to_s.capitalize}Result")
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
choria-mcorpc-support-2.26.5 lib/mcollective/aggregate/base.rb
choria-mcorpc-support-2.26.4 lib/mcollective/aggregate/base.rb
choria-mcorpc-support-2.26.3 lib/mcollective/aggregate/base.rb
choria-mcorpc-support-2.26.2 lib/mcollective/aggregate/base.rb
choria-mcorpc-support-2.26.1 lib/mcollective/aggregate/base.rb
choria-mcorpc-support-2.26.0 lib/mcollective/aggregate/base.rb
choria-mcorpc-support-2.25.3 lib/mcollective/aggregate/base.rb
choria-mcorpc-support-2.25.2 lib/mcollective/aggregate/base.rb
choria-mcorpc-support-2.25.1 lib/mcollective/aggregate/base.rb
choria-mcorpc-support-2.25.0 lib/mcollective/aggregate/base.rb
choria-mcorpc-support-2.24.4 lib/mcollective/aggregate/base.rb
choria-mcorpc-support-2.24.3 lib/mcollective/aggregate/base.rb
choria-mcorpc-support-2.24.2 lib/mcollective/aggregate/base.rb
choria-mcorpc-support-2.24.1 lib/mcollective/aggregate/base.rb
choria-mcorpc-support-2.24.0 lib/mcollective/aggregate/base.rb
choria-mcorpc-support-2.23.3 lib/mcollective/aggregate/base.rb
choria-mcorpc-support-2.23.2 lib/mcollective/aggregate/base.rb
choria-mcorpc-support-2.23.1 lib/mcollective/aggregate/base.rb
choria-mcorpc-support-2.23.0 lib/mcollective/aggregate/base.rb
choria-mcorpc-support-2.23.0.pre lib/mcollective/aggregate/base.rb