Class: TLAW::APIPath

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/tlaw/api_path.rb

Overview

Base class for all API pathes: entire API, namespaces and endpoints. Allows to define params and post-processors on any level.

Direct Known Subclasses

Endpoint, Namespace

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**parent_params) ⇒ APIPath

Returns a new instance of APIPath.



127
128
129
# File 'lib/tlaw/api_path.rb', line 127

def initialize(**parent_params)
  @parent_params = parent_params
end

Class Method Details

.describe(definition = nil) ⇒ Util::Description

Redefined on descendants, it just allows you to do api.namespace.describe or api.namespace1.namespace2.endpoints[:my_endpoint].describe and have reasonable useful description printed.

Returns:

  • (Util::Description)

    It is just description string but with redefined #inspect to be pretty-printed in console.



95
96
97
98
99
100
101
# File 'lib/tlaw/api_path.rb', line 95

def describe(definition = nil)
  Util::Description.new(
    ".#{definition || to_method_definition}" +
      (description ? "\n" + description.indent('  ') + "\n" : '') +
      (param_set.empty? ? '' : "\n" + param_set.describe.indent('  '))
  )
end

.param_setParamSet

Returns:



75
76
77
# File 'lib/tlaw/api_path.rb', line 75

def param_set
  @param_set ||= ParamSet.new
end