Class: Mountapi::Route::Parameter
- Inherits:
-
Object
- Object
- Mountapi::Route::Parameter
- Defined in:
- lib/mountapi/route/parameter.rb
Overview
Route parameter model used to carry schema definition
Instance Attribute Summary collapse
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
- #cast(value) ⇒ Object
- #default ⇒ Object
-
#initialize(name, location, options = OpenStruct.new) ⇒ Parameter
constructor
A new instance of Parameter.
- #json_schema ⇒ Object
- #required ⇒ Object
- #schema ⇒ Mountapi::Schema
Constructor Details
#initialize(name, location, options = OpenStruct.new) ⇒ Parameter
10 11 12 13 14 |
# File 'lib/mountapi/route/parameter.rb', line 10 def initialize(name, location, = OpenStruct.new) @name = name @location = location = end |
Instance Attribute Details
#location ⇒ Object (readonly)
Returns the value of attribute location.
8 9 10 |
# File 'lib/mountapi/route/parameter.rb', line 8 def location @location end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/mountapi/route/parameter.rb', line 8 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
8 9 10 |
# File 'lib/mountapi/route/parameter.rb', line 8 def end |
Class Method Details
.build(*args) ⇒ Object
37 38 39 |
# File 'lib/mountapi/route/parameter.rb', line 37 def self.build(*args) new(*args) end |
Instance Method Details
#cast(value) ⇒ Object
29 30 31 |
# File 'lib/mountapi/route/parameter.rb', line 29 def cast(value) json_schema["nullable"] && value.nil? ? value : schema.cast(value) end |
#default ⇒ Object
33 34 35 |
# File 'lib/mountapi/route/parameter.rb', line 33 def default schema.default end |
#json_schema ⇒ Object
25 26 27 |
# File 'lib/mountapi/route/parameter.rb', line 25 def json_schema @json_schema ||= schema.to_json_schema end |
#required ⇒ Object
16 17 18 |
# File 'lib/mountapi/route/parameter.rb', line 16 def required .required? end |
#schema ⇒ Mountapi::Schema
21 22 23 |
# File 'lib/mountapi/route/parameter.rb', line 21 def schema @schema ||= Mountapi::Schema.build(.schema) end |