Class: OasParser::Parameter
- Inherits:
-
Object
- Object
- OasParser::Parameter
show all
- Includes:
- RawAccessor
- Defined in:
- lib/oas_parser/parameter.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
included, #method_missing, #respond_to_missing?
Constructor Details
#initialize(owner, raw) ⇒ Parameter
Returns a new instance of Parameter.
9
10
11
12
|
# File 'lib/oas_parser/parameter.rb', line 9
def initialize(owner, raw)
@owner = owner
@raw = raw
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class OasParser::RawAccessor
Instance Attribute Details
#owner ⇒ Object
Returns the value of attribute owner.
7
8
9
|
# File 'lib/oas_parser/parameter.rb', line 7
def owner
@owner
end
|
#raw ⇒ Object
Returns the value of attribute raw.
7
8
9
|
# File 'lib/oas_parser/parameter.rb', line 7
def raw
@raw
end
|
Instance Method Details
#array? ⇒ Boolean
22
23
24
|
# File 'lib/oas_parser/parameter.rb', line 22
def array?
type == 'array'
end
|
#collection? ⇒ Boolean
30
31
32
|
# File 'lib/oas_parser/parameter.rb', line 30
def collection?
array? || object?
end
|
#convert_property_schema_to_properties(schema) ⇒ Object
52
53
54
55
56
|
# File 'lib/oas_parser/parameter.rb', line 52
def convert_property_schema_to_properties(schema)
schema.map do |name, definition|
OasParser::Property.new(self, raw, name, definition)
end
end
|
#default ⇒ Object
42
43
44
|
# File 'lib/oas_parser/parameter.rb', line 42
def default
raw['default'] || schema['default']
end
|
#example ⇒ Object
38
39
40
|
# File 'lib/oas_parser/parameter.rb', line 38
def example
raw['example'] || schema['example']
end
|
18
19
20
|
# File 'lib/oas_parser/parameter.rb', line 18
def format
raw['format'] || schema['format']
end
|
#items ⇒ Object
34
35
36
|
# File 'lib/oas_parser/parameter.rb', line 34
def items
schema['items']
end
|
#object? ⇒ Boolean
26
27
28
|
# File 'lib/oas_parser/parameter.rb', line 26
def object?
type == 'object'
end
|
#properties ⇒ Object
46
47
48
49
50
|
# File 'lib/oas_parser/parameter.rb', line 46
def properties
return convert_property_schema_to_properties(raw['properties']) if object?
return convert_property_schema_to_properties(items) if array?
nil
end
|
#type ⇒ Object
14
15
16
|
# File 'lib/oas_parser/parameter.rb', line 14
def type
raw['type'] || schema['type']
end
|