Class: Leftovers::ConfigLoader::BoolSchema

Inherits:
Schema
  • Object
show all
Defined in:
lib/leftovers/config_loader/bool_schema.rb

Class Method Summary collapse

Methods inherited from Schema

===, error

Class Method Details

.to_ruby(node) ⇒ Object



12
13
14
15
16
17
# File 'lib/leftovers/config_loader/bool_schema.rb', line 12

def to_ruby(node)
  case node.to_ruby
  when true, 'true' then true
  when false, 'false' then false
  end
end

.validate(node) ⇒ Object



7
8
9
10
# File 'lib/leftovers/config_loader/bool_schema.rb', line 7

def validate(node)
  error(node, 'be true or false') if to_ruby(node).nil?
  super
end