Class: OasParser::Property
- Inherits:
-
Object
- Object
- OasParser::Property
- Includes:
- RawAccessor
- Defined in:
- lib/oas_parser/property.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#owner ⇒ Object
Returns the value of attribute owner.
-
#raw ⇒ Object
Returns the value of attribute raw.
-
#schema ⇒ Object
Returns the value of attribute schema.
Instance Method Summary collapse
- #array? ⇒ Boolean
- #collection? ⇒ Boolean
- #convert_property_schema_to_properties(schema) ⇒ Object
-
#initialize(owner, schema, name, raw) ⇒ Property
constructor
A new instance of Property.
- #object? ⇒ Boolean
- #properties ⇒ Object
- #required ⇒ Object
Methods included from RawAccessor
included, #method_missing, #respond_to_missing?
Constructor Details
#initialize(owner, schema, name, raw) ⇒ Property
Returns a new instance of Property.
9 10 11 12 13 14 |
# File 'lib/oas_parser/property.rb', line 9 def initialize(owner, schema, name, raw) @owner = owner @name = name @schema = schema @raw = raw end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class OasParser::RawAccessor
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'lib/oas_parser/property.rb', line 7 def name @name end |
#owner ⇒ Object
Returns the value of attribute owner.
7 8 9 |
# File 'lib/oas_parser/property.rb', line 7 def owner @owner end |
#raw ⇒ Object
Returns the value of attribute raw.
7 8 9 |
# File 'lib/oas_parser/property.rb', line 7 def raw @raw end |
#schema ⇒ Object
Returns the value of attribute schema.
7 8 9 |
# File 'lib/oas_parser/property.rb', line 7 def schema @schema end |
Instance Method Details
#array? ⇒ Boolean
22 23 24 |
# File 'lib/oas_parser/property.rb', line 22 def array? type == 'array' end |
#collection? ⇒ Boolean
30 31 32 |
# File 'lib/oas_parser/property.rb', line 30 def collection? array? || object? end |
#convert_property_schema_to_properties(schema) ⇒ Object
40 41 42 43 44 45 |
# File 'lib/oas_parser/property.rb', line 40 def convert_property_schema_to_properties(schema) schema = schema['properties'] if schema['properties'] schema.map do |name, definition| OasParser::Property.new(self, raw, name, definition) end end |
#object? ⇒ Boolean
26 27 28 |
# File 'lib/oas_parser/property.rb', line 26 def object? type == 'object' end |
#properties ⇒ Object
34 35 36 37 38 |
# File 'lib/oas_parser/property.rb', line 34 def properties return convert_property_schema_to_properties(raw['properties']) if object? return convert_property_schema_to_properties(items) if array? nil end |
#required ⇒ Object
16 17 18 19 20 |
# File 'lib/oas_parser/property.rb', line 16 def required return true if raw['required'] return false unless schema['required'] schema['required'].include? name end |