Class: WSDSL::Response::Element::Attribute
- Inherits:
-
Object
- Object
- WSDSL::Response::Element::Attribute
- Defined in:
- lib/response.rb
Overview
Response element’s attribute class
Direct Known Subclasses
Instance Attribute Summary collapse
-
#doc ⇒ String
readonly
The documentation associated with this attribute.
-
#name ⇒ String, #to_s
(also: #value)
readonly
The attribute’s name.
-
#opts ⇒ Hash, ...
readonly
Could be a hash, nil or any object depending on how the attribute is created.
-
#type ⇒ Symbol, ...
readonly
The attribute’s type such as boolean, string etc..
Instance Method Summary collapse
-
#initialize(o_params, o_extra_params = {}) ⇒ Attribute
constructor
Takes a Hash or an Array and extract the attribute name, type doc and extra options.
Constructor Details
#initialize(o_params, o_extra_params = {}) ⇒ Attribute
Takes a Hash or an Array and extract the attribute name, type doc and extra options. If the passed objects is a Hash, the name will be extract from the first key and the type for the first value. An entry keyed by :doc will be used for the doc and the rest will go as extra options.
If an Array is passed, the elements will be ‘shifted’ in this order: name, type, doc, type
427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 |
# File 'lib/response.rb', line 427 def initialize(o_params, o_extra_params={}) params = o_params.dup extra_params = o_extra_params.dup if params.is_a?(Hash) @name, @type = params.shift @doc = params.delete(:doc) if params.has_key?(:doc) @doc ||= extra_params.delete(:doc) if extra_params.has_key?(:doc) @opts = params.merge!(extra_params) elsif params.is_a?(Array) @name = params.shift @type = params.shift @doc = params.shift @opts = params end end |
Instance Attribute Details
#doc ⇒ String (readonly)
Returns The documentation associated with this attribute.
406 407 408 |
# File 'lib/response.rb', line 406 def doc @doc end |
#name ⇒ String, #to_s (readonly) Also known as: value
Returns The attribute’s name.
397 398 399 |
# File 'lib/response.rb', line 397 def name @name end |
#opts ⇒ Hash, ... (readonly)
Returns Could be a hash, nil or any object depending on how the attribute is created.
411 412 413 |
# File 'lib/response.rb', line 411 def opts @opts end |
#type ⇒ Symbol, ... (readonly)
Returns The attribute’s type such as boolean, string etc..
402 403 404 |
# File 'lib/response.rb', line 402 def type @type end |