Class: SoarScRouting::RouterMeta
- Inherits:
-
Object
- Object
- SoarScRouting::RouterMeta
- Includes:
- Jsender
- Defined in:
- lib/soar_sc_routing/router_meta.rb
Constant Summary collapse
- SIGNED =
true- UNSIGNED =
false- AUTHORIZED =
true- UNAUTHORIZED =
false
Instance Attribute Summary collapse
-
#autenticate ⇒ Object
Returns the value of attribute autenticate.
-
#configuration ⇒ Object
Returns the value of attribute configuration.
-
#lexicon ⇒ Object
Returns the value of attribute lexicon.
-
#policy_am ⇒ Object
Returns the value of attribute policy_am.
-
#routing ⇒ Object
Returns the value of attribute routing.
-
#service_names ⇒ Object
Returns the value of attribute service_names.
-
#signed_routes ⇒ Object
Returns the value of attribute signed_routes.
Instance Method Summary collapse
- #access_manager ⇒ Object
- #add_route(path, description, &block) ⇒ Object
- #add_signed_route(path, description, &block) ⇒ Object
- #add_signed_unauthorized_route(path, description, &block) ⇒ Object
- #add_unsigned_unauthorized_route(path, description, &block) ⇒ Object
-
#initialize(configuration) ⇒ RouterMeta
constructor
A new instance of RouterMeta.
- #register_route(detail, startup_flow_id = nil) ⇒ Object
Constructor Details
#initialize(configuration) ⇒ RouterMeta
Returns a new instance of RouterMeta.
23 24 25 26 27 28 29 30 |
# File 'lib/soar_sc_routing/router_meta.rb', line 23 def initialize(configuration) @configuration = configuration @lexicon = {} @routing = {} @signed_routes = {} @service_names = {} setup_routing_table end |
Instance Attribute Details
#autenticate ⇒ Object
Returns the value of attribute autenticate.
21 22 23 |
# File 'lib/soar_sc_routing/router_meta.rb', line 21 def autenticate @autenticate end |
#configuration ⇒ Object
Returns the value of attribute configuration.
15 16 17 |
# File 'lib/soar_sc_routing/router_meta.rb', line 15 def configuration @configuration end |
#lexicon ⇒ Object
Returns the value of attribute lexicon.
16 17 18 |
# File 'lib/soar_sc_routing/router_meta.rb', line 16 def lexicon @lexicon end |
#policy_am ⇒ Object
Returns the value of attribute policy_am.
20 21 22 |
# File 'lib/soar_sc_routing/router_meta.rb', line 20 def policy_am @policy_am end |
#routing ⇒ Object
Returns the value of attribute routing.
17 18 19 |
# File 'lib/soar_sc_routing/router_meta.rb', line 17 def routing @routing end |
#service_names ⇒ Object
Returns the value of attribute service_names.
19 20 21 |
# File 'lib/soar_sc_routing/router_meta.rb', line 19 def service_names @service_names end |
#signed_routes ⇒ Object
Returns the value of attribute signed_routes.
18 19 20 |
# File 'lib/soar_sc_routing/router_meta.rb', line 18 def signed_routes @signed_routes end |
Instance Method Details
#access_manager ⇒ Object
32 33 34 |
# File 'lib/soar_sc_routing/router_meta.rb', line 32 def access_manager @policy_am end |
#add_route(path, description, &block) ⇒ Object
50 51 52 53 |
# File 'lib/soar_sc_routing/router_meta.rb', line 50 def add_route(path, description, &block) resource = SoarScRouting::Resource.new(description, generate_id(path)) add_resource_route(path, resource, UNSIGNED, AUTHORIZED, &block) end |
#add_signed_route(path, description, &block) ⇒ Object
60 61 62 63 |
# File 'lib/soar_sc_routing/router_meta.rb', line 60 def add_signed_route(path, description, &block) resource = SoarScRouting::Resource.new(description, generate_id(path)) add_resource_route(path, resource, SIGNED, AUTHORIZED, &block) end |
#add_signed_unauthorized_route(path, description, &block) ⇒ Object
65 66 67 68 |
# File 'lib/soar_sc_routing/router_meta.rb', line 65 def (path, description, &block) resource = SoarScRouting::Resource.new(description, generate_id(path)) add_resource_route(path, resource, SIGNED, UNAUTHORIZED, &block) end |
#add_unsigned_unauthorized_route(path, description, &block) ⇒ Object
55 56 57 58 |
# File 'lib/soar_sc_routing/router_meta.rb', line 55 def (path, description, &block) resource = SoarScRouting::Resource.new(description, generate_id(path)) add_resource_route(path, resource, UNSIGNED, UNAUTHORIZED, &block) end |
#register_route(detail, startup_flow_id = nil) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/soar_sc_routing/router_meta.rb', line 36 def register_route(detail, startup_flow_id = nil) validate_detail(detail) info("Registering service: #{detail}", startup_flow_id) resource = SoarScRouting::Resource.new(detail['description'], "#{detail['service_name']}", detail['method'].upcase, detail['params']) add_resource_route(detail['path'], resource, interpret_secured(detail), (detail)) do |request| if detail['controller'] delegate_to_controller_and_renderer(detail, startup_flow_id, request) elsif detail['action'] http_code, headers, body = detail['action'].call(request) [http_code, headers, [body]] end end end |