Class: Aikido::Zen::Collector::Routes Private
- Inherits:
-
Object
- Object
- Aikido::Zen::Collector::Routes
- Defined in:
- lib/aikido/zen/collector/routes.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Keeps track of the visited routes.
Defined Under Namespace
Classes: Record
Instance Attribute Summary collapse
-
#visits ⇒ Object
readonly
private
Visible for testing.
Instance Method Summary collapse
-
#[](route) ⇒ Object
private
Visible for testing.
- #add(route, schema) ⇒ void private
- #as_json ⇒ Object private
- #empty? ⇒ Boolean private
-
#initialize(config = Aikido::Zen.config) ⇒ Routes
constructor
private
A new instance of Routes.
Constructor Details
#initialize(config = Aikido::Zen.config) ⇒ Routes
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Routes.
14 15 16 17 |
# File 'lib/aikido/zen/collector/routes.rb', line 14 def initialize(config = Aikido::Zen.config) @config = config @visits = Hash.new { |h, k| h[k] = Record.new } end |
Instance Attribute Details
#visits ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Visible for testing.
12 13 14 |
# File 'lib/aikido/zen/collector/routes.rb', line 12 def visits @visits end |
Instance Method Details
#[](route) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Visible for testing.
39 40 41 |
# File 'lib/aikido/zen/collector/routes.rb', line 39 def [](route) @visits[route] end |
#add(route, schema) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
22 23 24 |
# File 'lib/aikido/zen/collector/routes.rb', line 22 def add(route, schema) @visits[route].increment(schema) unless route.nil? end |
#as_json ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/aikido/zen/collector/routes.rb', line 26 def as_json @visits.map do |route, record| { method: route.verb, path: route.path, hits: record.hits, apispec: record.schema.as_json }.compact end end |
#empty? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
44 45 46 |
# File 'lib/aikido/zen/collector/routes.rb', line 44 def empty? @visits.empty? end |