Method: WSDSL::Response#element

Defined in:
lib/response.rb

#element(opts = {}) {|WSDSL::Response::Element| ... } ⇒ WSDSL::Response::Element

Defines a new element and yields the content of an optional block Each new element is then stored in the elements array.

Examples:

create an element called ‘my_stats’.

service.response do |response|
 response.element(:name => "my_stats", :type => 'Leaderboard')
end

Parameters:

  • opts (Hash) (defaults to: {})

    Options used to define the element

Options Hash (opts):

  • :name (String, Symbol)

    The element name

  • :type (String, Symbol)

    The optional type

Yields:

Returns:

Since:

  • 0.0.3



58
59
60
61
62
63
# File 'lib/response.rb', line 58

def element(opts={})
  el = Element.new(opts[:name], opts[:type])
  yield(el) if block_given?
  @elements << el
  el
end