Class: Openapi3Parser::NodeFactory::Field

Inherits:
Object
  • Object
show all
Defined in:
lib/openapi3_parser/node_factory/field.rb

Defined Under Namespace

Classes: ValidNodeBuilder

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context, input_type: nil, validate: nil) ⇒ Field

Returns a new instance of Field.



8
9
10
11
12
# File 'lib/openapi3_parser/node_factory/field.rb', line 8

def initialize(context, input_type: nil, validate: nil)
  @context = context
  @input_type = input_type
  @validation = validate
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



6
7
8
# File 'lib/openapi3_parser/node_factory/field.rb', line 6

def context
  @context
end

#input_typeObject (readonly)

Returns the value of attribute input_type.



6
7
8
# File 'lib/openapi3_parser/node_factory/field.rb', line 6

def input_type
  @input_type
end

#validationObject (readonly)

Returns the value of attribute validation.



6
7
8
# File 'lib/openapi3_parser/node_factory/field.rb', line 6

def validation
  @validation
end

Instance Method Details

#dataObject



14
15
16
# File 'lib/openapi3_parser/node_factory/field.rb', line 14

def data
  context.input
end

#defaultObject



34
35
36
# File 'lib/openapi3_parser/node_factory/field.rb', line 34

def default
  nil
end

#errorsObject



38
39
40
# File 'lib/openapi3_parser/node_factory/field.rb', line 38

def errors
  @errors ||= ValidNodeBuilder.errors(self)
end

#inspectObject



47
48
49
# File 'lib/openapi3_parser/node_factory/field.rb', line 47

def inspect
  %{#{self.class.name}(#{context.source_location.inspect})}
end

#nil_input?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/openapi3_parser/node_factory/field.rb', line 26

def nil_input?
  context.input.nil?
end

#node(node_context) ⇒ Object



42
43
44
45
# File 'lib/openapi3_parser/node_factory/field.rb', line 42

def node(node_context)
  data = ValidNodeBuilder.data(self)
  data.nil? ? nil : build_node(data, node_context)
end

#raw_inputObject



22
23
24
# File 'lib/openapi3_parser/node_factory/field.rb', line 22

def raw_input
  context.input
end

#resolved_inputObject



18
19
20
# File 'lib/openapi3_parser/node_factory/field.rb', line 18

def resolved_input
  context.input
end

#valid?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/openapi3_parser/node_factory/field.rb', line 30

def valid?
  errors.empty?
end