Class: Openapi3Parser::NodeFactory::Object

Inherits:
Object
  • Object
show all
Extended by:
Forwardable, Openapi3Parser::NodeFactory::ObjectFactory::Dsl
Defined in:
lib/openapi3_parser/node_factory/object.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Openapi3Parser::NodeFactory::ObjectFactory::Dsl

allow_extensions, allowed_extensions?, field, field_configs, mutually_exclusive, mutually_exclusive_fields, validate, validations

Constructor Details

#initialize(context) ⇒ Object

Returns a new instance of Object.



24
25
26
27
# File 'lib/openapi3_parser/node_factory/object.rb', line 24

def initialize(context)
  @context = context
  @data = build_data(context.input)
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



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

def context
  @context
end

#dataObject (readonly)

Returns the value of attribute data.



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

def data
  @data
end

Instance Method Details

#allowed_fieldsObject



61
62
63
# File 'lib/openapi3_parser/node_factory/object.rb', line 61

def allowed_fields
  field_configs.keys
end

#can_use_default?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/openapi3_parser/node_factory/object.rb', line 53

def can_use_default?
  true
end

#defaultObject



57
58
59
# File 'lib/openapi3_parser/node_factory/object.rb', line 57

def default
  nil
end

#errorsObject



45
46
47
# File 'lib/openapi3_parser/node_factory/object.rb', line 45

def errors
  @errors ||= ObjectFactory::NodeBuilder.errors(self)
end

#inspectObject



71
72
73
# File 'lib/openapi3_parser/node_factory/object.rb', line 71

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

#nil_input?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/openapi3_parser/node_factory/object.rb', line 37

def nil_input?
  context.input.nil?
end

#nodeObject



49
50
51
# File 'lib/openapi3_parser/node_factory/object.rb', line 49

def node
  @node ||= build_node
end

#raw_inputObject



33
34
35
# File 'lib/openapi3_parser/node_factory/object.rb', line 33

def raw_input
  context.input
end

#required_fieldsObject



65
66
67
68
69
# File 'lib/openapi3_parser/node_factory/object.rb', line 65

def required_fields
  field_configs.each_with_object([]) do |(key, config), memo|
    memo << key if config.required?
  end
end

#resolved_inputObject



29
30
31
# File 'lib/openapi3_parser/node_factory/object.rb', line 29

def resolved_input
  @resolved_input ||= build_resolved_input
end

#valid?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/openapi3_parser/node_factory/object.rb', line 41

def valid?
  errors.empty?
end