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

#default_value, human_name, #required?, #validate

Methods included from Common

#default, #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



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

def is(value)
  options[:is] = Coercion.coerce!(value, Coercion::Array)
  self
end

#items(schema) ⇒ Object



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

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

  options[:items] = schema
  self
end