Class: RubstApi::Param
- Inherits:
-
Object
- Object
- RubstApi::Param
- Defined in:
- lib/rubst_api/params.rb
Instance Attribute Summary collapse
-
#alias_name ⇒ Object
readonly
Returns the value of attribute alias_name.
-
#constraints ⇒ Object
readonly
Returns the value of attribute constraints.
-
#default ⇒ Object
readonly
Returns the value of attribute default.
-
#deprecated ⇒ Object
readonly
Returns the value of attribute deprecated.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#examples ⇒ Object
readonly
Returns the value of attribute examples.
-
#include_in_schema ⇒ Object
readonly
Returns the value of attribute include_in_schema.
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(location, type: String, default: UNDEFINED, required: nil, alias_name: nil, alias: nil, title: nil, description: nil, examples: nil, deprecated: false, include_in_schema: true, **constraints) ⇒ Param
constructor
A new instance of Param.
- #name_for(name) ⇒ Object
- #required? ⇒ Boolean
Constructor Details
#initialize(location, type: String, default: UNDEFINED, required: nil, alias_name: nil, alias: nil, title: nil, description: nil, examples: nil, deprecated: false, include_in_schema: true, **constraints) ⇒ Param
Returns a new instance of Param.
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/rubst_api/params.rb', line 10 def initialize(location, type: String, default: UNDEFINED, required: nil, alias_name: nil, alias: nil, title: nil, description: nil, examples: nil, deprecated: false, include_in_schema: true, **constraints) @location, @type, @default = location, type, default @required = required.nil? ? default.equal?(UNDEFINED) : required @alias_name = alias_name || binding.local_variable_get(:alias) @title, @description, @examples = title, description, examples @deprecated, @include_in_schema = deprecated, include_in_schema @constraints = constraints end |
Instance Attribute Details
#alias_name ⇒ Object (readonly)
Returns the value of attribute alias_name.
7 8 9 |
# File 'lib/rubst_api/params.rb', line 7 def alias_name @alias_name end |
#constraints ⇒ Object (readonly)
Returns the value of attribute constraints.
7 8 9 |
# File 'lib/rubst_api/params.rb', line 7 def constraints @constraints end |
#default ⇒ Object (readonly)
Returns the value of attribute default.
7 8 9 |
# File 'lib/rubst_api/params.rb', line 7 def default @default end |
#deprecated ⇒ Object (readonly)
Returns the value of attribute deprecated.
7 8 9 |
# File 'lib/rubst_api/params.rb', line 7 def deprecated @deprecated end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
7 8 9 |
# File 'lib/rubst_api/params.rb', line 7 def description @description end |
#examples ⇒ Object (readonly)
Returns the value of attribute examples.
7 8 9 |
# File 'lib/rubst_api/params.rb', line 7 def examples @examples end |
#include_in_schema ⇒ Object (readonly)
Returns the value of attribute include_in_schema.
7 8 9 |
# File 'lib/rubst_api/params.rb', line 7 def include_in_schema @include_in_schema end |
#location ⇒ Object (readonly)
Returns the value of attribute location.
7 8 9 |
# File 'lib/rubst_api/params.rb', line 7 def location @location end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
7 8 9 |
# File 'lib/rubst_api/params.rb', line 7 def title @title end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
7 8 9 |
# File 'lib/rubst_api/params.rb', line 7 def type @type end |
Instance Method Details
#name_for(name) ⇒ Object
22 |
# File 'lib/rubst_api/params.rb', line 22 def name_for(name) = (alias_name || name).to_s |
#required? ⇒ Boolean
21 |
# File 'lib/rubst_api/params.rb', line 21 def required? = @required |