Class: Leftovers::ConfigLoader::ValueOrArraySchema

Inherits:
ArraySchema show all
Defined in:
lib/leftovers/config_loader/value_or_array_schema.rb

Instance Attribute Summary

Attributes inherited from ArraySchema

#value_schema

Instance Method Summary collapse

Methods inherited from ArraySchema

[], #initialize

Methods inherited from Schema

===, error, to_ruby, validate

Constructor Details

This class inherits a constructor from Leftovers::ConfigLoader::ArraySchema

Instance Method Details

#to_ruby(node) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/leftovers/config_loader/value_or_array_schema.rb', line 14

def to_ruby(node)
  if node.array?
    ::Leftovers.unwrap_array(super)
  else
    value_schema.to_ruby(node)
  end
end

#validate(node) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/leftovers/config_loader/value_or_array_schema.rb', line 6

def validate(node)
  if node.array?
    validate_length(node) && validate_values(node)
  else
    validate_or_schema(node)
  end
end