Class: Hyperdrive::Param
- Inherits:
-
Object
- Object
- Hyperdrive::Param
- Defined in:
- lib/hyperdrive/param.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#constraints ⇒ Object
readonly
Returns the value of attribute constraints.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#required ⇒ Object
readonly
Returns the value of attribute required.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(name, description, options = {}) ⇒ Param
constructor
A new instance of Param.
- #required?(http_request_method) ⇒ Boolean
- #to_hash ⇒ Object
Constructor Details
#initialize(name, description, options = {}) ⇒ Param
Returns a new instance of Param.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/hyperdrive/param.rb', line 7 def initialize(name, description, = {}) @name = name.to_s @description = description = .merge() @required = if [:required] == true %w(POST PUT PATCH) elsif [:required] == false [] else Array([:required]) end @type = [:type] @constraints = "#{required_constraint} #{[:constraints]}" end |
Instance Attribute Details
#constraints ⇒ Object (readonly)
Returns the value of attribute constraints.
5 6 7 |
# File 'lib/hyperdrive/param.rb', line 5 def constraints @constraints end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
5 6 7 |
# File 'lib/hyperdrive/param.rb', line 5 def description @description end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/hyperdrive/param.rb', line 5 def name @name end |
#required ⇒ Object (readonly)
Returns the value of attribute required.
5 6 7 |
# File 'lib/hyperdrive/param.rb', line 5 def required @required end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
5 6 7 |
# File 'lib/hyperdrive/param.rb', line 5 def type @type end |
Instance Method Details
#required?(http_request_method) ⇒ Boolean
22 23 24 |
# File 'lib/hyperdrive/param.rb', line 22 def required?(http_request_method) @required.include? http_request_method end |
#to_hash ⇒ Object
26 27 28 |
# File 'lib/hyperdrive/param.rb', line 26 def to_hash { name: @name, description: @description, type: @type, constraints: @constraints } end |