Sha256: 4333a64185c84724f6df0ea4d67ab526b91fa901ae51a7230a16be9113e6f54f

Contents?: true

Size: 852 Bytes

Versions: 1

Compression:

Stored size: 852 Bytes

Contents

module ROM
  module Plugins
    module Command
      # @api private
      module Schema
        def self.included(klass)
          super
          klass.extend(ClassInterface)
        end

        # @api private
        module ClassInterface
          # @see Command.build
          # @api public
          def build(relation, options = {})
            if options.key?(:input) || !relation.schema?
              super
            else
              default_input = options.fetch(:input, input)

              input_handler =
                if default_input != Hash
                  -> tuple { relation.input_schema[input[tuple]] }
                else
                  relation.input_schema
                end

              super(relation, options.merge(input: input_handler))
            end
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rom-core-4.0.0.beta3 lib/rom/plugins/command/schema.rb