Class: Usher::Node::Response

Inherits:
Struct
  • Object
show all
Defined in:
lib/usher/node/response.rb

Overview

The response from Usher::Node::Root#lookup. Adds some convenience methods for common parameter manipulation.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#matched_pathObject

Returns the value of attribute matched_path

Returns:

  • (Object)

    the current value of matched_path



4
5
6
# File 'lib/usher/node/response.rb', line 4

def matched_path
  @matched_path
end

#metaObject

Returns the value of attribute meta

Returns:

  • (Object)

    the current value of meta



4
5
6
# File 'lib/usher/node/response.rb', line 4

def meta
  @meta
end

#only_trailing_delimitersObject

Returns the value of attribute only_trailing_delimiters

Returns:

  • (Object)

    the current value of only_trailing_delimiters



4
5
6
# File 'lib/usher/node/response.rb', line 4

def only_trailing_delimiters
  @only_trailing_delimiters
end

#params_as_arrayObject

Returns the value of attribute params_as_array

Returns:

  • (Object)

    the current value of params_as_array



4
5
6
# File 'lib/usher/node/response.rb', line 4

def params_as_array
  @params_as_array
end

#pathObject

Returns the value of attribute path

Returns:

  • (Object)

    the current value of path



4
5
6
# File 'lib/usher/node/response.rb', line 4

def path
  @path
end

#remaining_pathObject

Returns the value of attribute remaining_path

Returns:

  • (Object)

    the current value of remaining_path



4
5
6
# File 'lib/usher/node/response.rb', line 4

def remaining_path
  @remaining_path
end

Instance Method Details

#destinationObject

Returns The destination assigned to the matching enclosed path.

Returns:

  • (Object)

    The destination assigned to the matching enclosed path.



30
31
32
# File 'lib/usher/node/response.rb', line 30

def destination
  path && path.route.destination
end

#paramsArray<Symbol, String>

The params from recognition

Returns:

  • (Array<Symbol, String>)

    The parameters detected from recognition returned as an array of arrays.



14
15
16
# File 'lib/usher/node/response.rb', line 14

def params
  @params ||= path.convert_params_array(params_as_array)
end

#params_as_hashHash<Symbol, String>

The params from recognition

Returns:

  • (Hash<Symbol, String>)

    The parameters detected from recognition returned as a hash.



25
26
27
# File 'lib/usher/node/response.rb', line 25

def params_as_hash
  @params_as_hash ||= params_as_array.inject({}){|hash, val| hash[path.dynamic_keys[hash.size]] = val; hash}
end

#partial_match?Boolean

Returns The state of partial matching.

Returns:

  • (Boolean)

    The state of partial matching



19
20
21
# File 'lib/usher/node/response.rb', line 19

def partial_match?
  !remaining_path.nil?
end

#succeeded?Boolean

The success of the response

Returns:

  • (Boolean)

    Always returns true



8
9
10
# File 'lib/usher/node/response.rb', line 8

def succeeded?
  true
end