module Setsuzoku::Service
Core service required for a web service plugin. It should be able to register all of its available api and auth strategies. It acts as the orchestration between a plugin, auth_strategy
, and api_strategy.
Attributes
api_strategy[RW]
auth_strategy[RW]
external_api_handler[RW]
plugin[RW]
Public Class Methods
included(klass)
click to toggle source
# File lib/setsuzoku/service.rb, line 23 def self.included(klass) klass.extend(ClassMethods) end
new(plugin:, strategies:, **args)
click to toggle source
# File lib/setsuzoku/service.rb, line 53 def initialize(plugin:, strategies:, **args) #TODO: here we need to assign credentials etc, I think. self.plugin = plugin self.external_api_handler = Setsuzoku.external_api_handler.new # iterate over all strategies this plugin's service uses and set their configuration strategies.each do |strategy, attrs| # get the strategy type from auth_strategy/api_strategy etc. type = T.must(strategy.to_s.split("_strategy").first).to_sym strat = attrs[:strategy] # associate the strategy with the service self.send("#{strategy}=", self.class.available_strategies[type][strat].new(service: self, credential: args[:credential], **attrs.except(:strategy))) end self end