Class: Aikido::Zen::RuntimeSettings::Endpoints
- Inherits:
-
Object
- Object
- Aikido::Zen::RuntimeSettings::Endpoints
- Defined in:
- lib/aikido/zen/runtime_settings/endpoints.rb
Overview
Wraps the list of endpoint protection settings, providing an interface for checking the settings for any given route. If the route has no configured settings, that will return the singleton ProtectionSettings.none.
Class Method Summary collapse
Instance Method Summary collapse
- #[](route) ⇒ Aikido::Zen::RuntimeSettings::ProtectionSettings
-
#initialize(data = {}) ⇒ Endpoints
constructor
A new instance of Endpoints.
Constructor Details
#initialize(data = {}) ⇒ Endpoints
Returns a new instance of Endpoints.
28 29 30 31 |
# File 'lib/aikido/zen/runtime_settings/endpoints.rb', line 28 def initialize(data = {}) @endpoints = data @endpoints.default = RuntimeSettings::ProtectionSettings.none end |
Class Method Details
.from_json(data) ⇒ Aikido::Zen::RuntimeSettings::Endpoints
18 19 20 21 22 23 24 25 26 |
# File 'lib/aikido/zen/runtime_settings/endpoints.rb', line 18 def self.from_json(data) data = Array(data).map { |item| route = Route.new(verb: item["method"], path: item["route"]) settings = RuntimeSettings::ProtectionSettings.from_json(item) [route, settings] }.to_h new(data) end |
Instance Method Details
#[](route) ⇒ Aikido::Zen::RuntimeSettings::ProtectionSettings
35 36 37 |
# File 'lib/aikido/zen/runtime_settings/endpoints.rb', line 35 def [](route) @endpoints[route] end |