class Schemacop::V2::NodeSupportingField
Attributes
fields[R]
Public Class Methods
new(options = {}, &block)
click to toggle source
Calls superclass method
# File lib/schemacop/v2/node_supporting_field.rb, line 12 def initialize(options = {}, &block) @fields = {} super exec_block(&block) end
Public Instance Methods
opt!(*args, **kwargs, &block)
click to toggle source
# 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)
click to toggle source
# 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
Also aliased as: opt
req!(*args, **kwargs, &block)
click to toggle source
# 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
Also aliased as: req
req?(*args, **kwargs, &block)
click to toggle source
# 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
Protected Instance Methods
field(*args, **kwargs, &block)
click to toggle source
# File lib/schemacop/v2/node_supporting_field.rb, line 52 def field(*args, **kwargs, &block) name = args.shift required = kwargs.delete(:required) allow_nil = kwargs.delete(:allow_nil) if @fields[name] @fields[name].type(*args, **kwargs, &block) elsif args.any? @fields[name] = FieldNode.new(name, required) do type(*args, **kwargs, &block) end else @fields[name] = FieldNode.new(name, required, &block) end @fields[name].type(:nil) if allow_nil end