Class: Schemacop::V2::NodeSupportingField
Instance Attribute Summary collapse
Attributes inherited from Node
#options
Instance Method Summary
collapse
block_method, #exec_block
Methods inherited from Node
build, class_matches?, clear_klasses, clear_symbols, #exec_block, klass, option, #option, #option?, register, #resolve_type_klass, symbol, symbol_matches?, #type_filter_matches?, #type_label, type_matches?, #type_matches?, #validate
Constructor Details
Returns a new instance of NodeSupportingField.
12
13
14
15
16
|
# File 'lib/schemacop/v2/node_supporting_field.rb', line 12
def initialize(options = {}, &block)
@fields = {}
super
exec_block(&block)
end
|
Instance Attribute Details
#fields ⇒ Object
Returns the value of attribute fields.
10
11
12
|
# File 'lib/schemacop/v2/node_supporting_field.rb', line 10
def fields
@fields
end
|
Instance Method Details
#opt!(*args, **kwargs, &block) ⇒ Object
41
42
43
44
45
46
|
# File 'lib/schemacop/v2/node_supporting_field.rb', line 41
def opt!(*args, **kwargs, &block)
kwargs ||= {}
kwargs[:required] = false
kwargs[:allow_nil] = false
field(*args, **kwargs, &block)
end
|
#opt?(*args, **kwargs, &block) ⇒ Boolean
Also known as:
opt
34
35
36
37
38
39
|
# File 'lib/schemacop/v2/node_supporting_field.rb', line 34
def opt?(*args, **kwargs, &block)
kwargs ||= {}
kwargs[:required] = false
kwargs[:allow_nil] = true
field(*args, **kwargs, &block)
end
|
#req!(*args, **kwargs, &block) ⇒ Object
Also known as:
req
25
26
27
28
29
30
|
# File 'lib/schemacop/v2/node_supporting_field.rb', line 25
def req!(*args, **kwargs, &block)
kwargs ||= {}
kwargs[:required] = true
kwargs[:allow_nil] = false
field(*args, **kwargs, &block)
end
|
#req?(*args, **kwargs, &block) ⇒ Boolean
18
19
20
21
22
23
|
# File 'lib/schemacop/v2/node_supporting_field.rb', line 18
def req?(*args, **kwargs, &block)
kwargs ||= {}
kwargs[:required] = true
kwargs[:allow_nil] = true
field(*args, **kwargs, &block)
end
|