Class: Schemacop::V3::BooleanNode
- Inherits:
-
Node
- Object
- Node
- Schemacop::V3::BooleanNode
show all
- Defined in:
- lib/schemacop/v3/boolean_node.rb
Instance Attribute Summary
Attributes inherited from Node
#as, #default, #description, #name, #options, #parent, #require_key, #title
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Node
#children, #create, create, dsl_methods, #dsl_node, #dsl_scm, #init, #initialize, #require_key?, #required?, resolve_class, #schemas, supports_children, supports_children_options, #used_external_schemas, #validate
Class Method Details
.allowed_options ⇒ Object
23
24
25
|
# File 'lib/schemacop/v3/boolean_node.rb', line 23
def self.allowed_options
super + %i[cast_str]
end
|
Instance Method Details
#allowed_types ⇒ Object
8
9
10
11
12
13
|
# File 'lib/schemacop/v3/boolean_node.rb', line 8
def allowed_types
{
TrueClass => :boolean,
FalseClass => :boolean
}
end
|
#as_json ⇒ Object
4
5
6
|
# File 'lib/schemacop/v3/boolean_node.rb', line 4
def as_json
process_json([], type: :boolean)
end
|
#cast(value) ⇒ Object
15
16
17
18
19
20
21
|
# File 'lib/schemacop/v3/boolean_node.rb', line 15
def cast(value)
if value.is_a?(TrueClass) || value.is_a?(FalseClass)
value
else
default
end
end
|