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

Class Method 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.



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

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

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



19
20
21
# File 'lib/openapi3_parser/node_factory/object.rb', line 19

def context
  @context
end

#dataObject (readonly)

Returns the value of attribute data.



19
20
21
# File 'lib/openapi3_parser/node_factory/object.rb', line 19

def data
  @data
end

Class Method Details

.object_typeObject



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

def self.object_type
  to_s
end

Instance Method Details

#allowed_fieldsObject



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

def allowed_fields
  field_configs.keys
end

#can_use_default?Boolean

Returns:

  • (Boolean)


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

def can_use_default?
  true
end

#defaultObject



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

def default
  nil
end

#errorsObject



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

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

#inspectObject



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

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

#nil_input?Boolean

Returns:

  • (Boolean)


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

def nil_input?
  context.input.nil?
end

#node(node_context) ⇒ Object



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

def node(node_context)
  build_node(node_context)
end

#raw_inputObject



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

def raw_input
  context.input
end

#required_fieldsObject



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

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

#resolved_inputObject



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

def resolved_input
  @resolved_input ||= build_resolved_input
end

#valid?Boolean

Returns:

  • (Boolean)


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

def valid?
  errors.empty?
end