Class: Schemacop::NodeSupportingField

Inherits:
NodeWithBlock show all
Defined in:
lib/schemacop/node_supporting_field.rb

Direct Known Subclasses

HashValidator

Instance Attribute Summary collapse

Attributes inherited from Node

#options

Instance Method Summary collapse

Methods inherited from NodeWithBlock

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

#initialize(options = {}, &block) ⇒ NodeSupportingField

Returns a new instance of NodeSupportingField



12
13
14
15
16
# File 'lib/schemacop/node_supporting_field.rb', line 12

def initialize(options = {}, &block)
  @fields = {}
  super
  exec_block(&block)
end

Instance Attribute Details

#fieldsObject (readonly)

Returns the value of attribute fields



10
11
12
# File 'lib/schemacop/node_supporting_field.rb', line 10

def fields
  @fields
end

Instance Method Details

#opt!(*args, &block) ⇒ Object



32
33
34
# File 'lib/schemacop/node_supporting_field.rb', line 32

def opt!(*args, &block)
  field(*args, required: false, allow_nil: false, &block)
end

#opt?(*args, &block) ⇒ Boolean Also known as: opt

Returns:

  • (Boolean)


28
29
30
# File 'lib/schemacop/node_supporting_field.rb', line 28

def opt?(*args, &block)
  field(*args, required: false, allow_nil: true, &block)
end

#req!(*args, &block) ⇒ Object Also known as: req



22
23
24
# File 'lib/schemacop/node_supporting_field.rb', line 22

def req!(*args, &block)
  field(*args, required: true, allow_nil: false, &block)
end

#req?(*args, &block) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/schemacop/node_supporting_field.rb', line 18

def req?(*args, &block)
  field(*args, required: true, allow_nil: true, &block)
end