Sha256: e67fdc378340cb1d403f51a06ba9e3c23b1c675fecac41f112ede039621e7718

Contents?: true

Size: 943 Bytes

Versions: 18

Compression:

Stored size: 943 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 && relation.schema?
                  -> tuple { relation.input_schema[input[tuple]] }
                elsif relation.schema?
                  relation.input_schema
                else
                  default_input
                end

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

Version data entries

18 entries across 18 versions & 2 rubygems

Version Path
rom-3.3.3 lib/rom/plugins/command/schema.rb
rom-3.3.2 lib/rom/plugins/command/schema.rb
rom-3.3.1 lib/rom/plugins/command/schema.rb
rom-core-4.0.0.beta2 lib/rom/plugins/command/schema.rb
rom-3.3.0 lib/rom/plugins/command/schema.rb
rom-core-4.0.0.beta1 lib/rom/plugins/command/schema.rb
rom-3.2.3 lib/rom/plugins/command/schema.rb
rom-3.2.2 lib/rom/plugins/command/schema.rb
rom-3.2.1 lib/rom/plugins/command/schema.rb
rom-3.2.0 lib/rom/plugins/command/schema.rb
rom-3.1.0 lib/rom/plugins/command/schema.rb
rom-3.0.3 lib/rom/plugins/command/schema.rb
rom-3.0.2 lib/rom/plugins/command/schema.rb
rom-3.0.1 lib/rom/plugins/command/schema.rb
rom-3.0.0 lib/rom/plugins/command/schema.rb
rom-3.0.0.rc2 lib/rom/plugins/command/schema.rb
rom-3.0.0.rc1 lib/rom/plugins/command/schema.rb
rom-3.0.0.beta3 lib/rom/plugins/command/schema.rb