Module: Inquery::Mixins::SchemaValidation::ClassMethods

Defined in:
lib/inquery/mixins/schema_validation.rb

Instance Method Summary collapse

Instance Method Details

#schema(*args, &block) ⇒ Object

See Also:



25
26
27
28
29
30
31
32
33
34
# File 'lib/inquery/mixins/schema_validation.rb', line 25

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

#schema2(*args, &block) ⇒ Object



12
13
14
# File 'lib/inquery/mixins/schema_validation.rb', line 12

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

#schema3(reference = nil, **options, &block) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/inquery/mixins/schema_validation.rb', line 16

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