Class: Compel::Builder::Array

Inherits:
Schema
  • Object
show all
Defined in:
lib/compel/builder/array.rb

Instance Attribute Summary

Attributes inherited from Schema

#options, #type

Instance Method Summary collapse

Methods inherited from Schema

#build_option, #default_options, #default_value, human_name, #required?, #validate

Methods included from Common

#coerce_if_proc, #default, #if, #length, #max_length, #min_length, #required

Constructor Details

#initializeArray

Returns a new instance of Array.



6
7
8
# File 'lib/compel/builder/array.rb', line 6

def initialize
  super(Coercion::Array)
end

Instance Method Details

#is(value) ⇒ Object



18
19
20
# File 'lib/compel/builder/array.rb', line 18

def is(value)
  build_option :is, Coercion.coerce!(value, Coercion::Array)
end

#items(schema, options = {}) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/compel/builder/array.rb', line 10

def items(schema, options = {})
  if !schema.is_a?(Schema)
    raise Compel::TypeError, '#items must be a valid Schema'
  end

  build_option :items, schema, options
end