Sha256: aed48bfb1fec0441fd6b23c3e3f56b5712555f938a6ba49d4040915f46362dd8

Contents?: true

Size: 1.46 KB

Versions: 14

Compression:

Stored size: 1.46 KB

Contents

module HaveAPI::GoClient
  class Metadata
    class Type
      # @return [InputOutput, nil]
      attr_reader :input

      # @return [InputOutput, nil]
      attr_reader :output

      def initialize(action, type, desc)
        @input = desc[:input] && InputOutput.new(
          action,
          :"#{type}_meta",
          :input,
          desc[:input],
          prefix: "Meta#{type.to_s.capitalize}"
        )
        @output = desc[:output] && InputOutput.new(
          action,
          :"#{type}_meta",
          :output,
          desc[:output],
          prefix: "Meta#{type.to_s.capitalize}"
        )
      end

      def resolve_associations
        input && input.resolve_associations
        output && output.resolve_associations
      end
    end

    # @return [Type, nil]
    attr_reader :global

    # @return [Type, nil]
    attr_reader :object

    def initialize(action, desc)
      @global = desc[:global] && Type.new(action, :global, desc[:global])
      @object = desc[:object] && Type.new(action, :object, desc[:object])
    end

    def resolve_associations
      global && global.resolve_associations
      object && object.resolve_associations
    end

    %i[global object].each do |type|
      %i[input output].each do |dir|
        define_method(:"has_#{type}_#{dir}?") do
          t = send(type)
          next(false) unless t

          io = t.send(dir)
          next(false) unless io

          io.parameters.any?
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
haveapi-go-client-0.25.0 lib/haveapi/go_client/metadata.rb
haveapi-go-client-0.24.0 lib/haveapi/go_client/metadata.rb
haveapi-go-client-0.23.7 lib/haveapi/go_client/metadata.rb
haveapi-go-client-0.23.6 lib/haveapi/go_client/metadata.rb
haveapi-go-client-0.23.5 lib/haveapi/go_client/metadata.rb
haveapi-go-client-0.23.4 lib/haveapi/go_client/metadata.rb
haveapi-go-client-0.23.3 lib/haveapi/go_client/metadata.rb
haveapi-go-client-0.23.2 lib/haveapi/go_client/metadata.rb
haveapi-go-client-0.23.1 lib/haveapi/go_client/metadata.rb
haveapi-go-client-0.23.0 lib/haveapi/go_client/metadata.rb
haveapi-go-client-0.22.1 lib/haveapi/go_client/metadata.rb
haveapi-go-client-0.22.0 lib/haveapi/go_client/metadata.rb
haveapi-go-client-0.21.1 lib/haveapi/go_client/metadata.rb
haveapi-go-client-0.21.0 lib/haveapi/go_client/metadata.rb