Sha256: a042e66b233ecef16555057521e3a1fa2cee1013a0f63bef3392d92ce3ac9d1f

Contents?: true

Size: 956 Bytes

Versions: 1

Compression:

Stored size: 956 Bytes

Contents

module Inquery
  module Mixins
    module SchemaValidation
      extend ActiveSupport::Concern

      included do
        class_attribute :_schema
        self._schema = nil
      end

      module ClassMethods
        def schema2(*args, &block)
          self._schema = Schemacop::Schema.new(*args, &block)
        end

        def schema3(reference = nil, **options, &block)
          if reference
            self._schema = Schemacop::Schema3.new(:reference, options.merge(path: reference))
          else
            self._schema = Schemacop::Schema3.new(:hash, **options, &block)
          end
        end

        # @see schema2
        def schema(*args, &block)
          case Inquery.default_schema_version
          when 2
            schema2(*args, &block)
          when 3
            schema3(*args, &block)
          else
            fail 'Schemacop schema versions supported are 2 and 3.'
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
inquery-1.0.11 lib/inquery/mixins/schema_validation.rb