class Tenantify::Middleware::Builder
This class builds all the strategies and injects them into a Strategies
object.
Constants
- KNOWN_STRATEGIES
Known strategies. They can be specified with a symbol.
- UnknownStrategyError
Invalid strategy specification
Attributes
config[R]
@return [Tenantify::Configuration] given configuration.
known_strategies[R]
Public Class Methods
new(config, known_strategies: KNOWN_STRATEGIES)
click to toggle source
Constructor.
@param [Tenantify::Configuration] the tenantify configuration. @param [Hash] a correspondence between strategy names and classes.
# File lib/tenantify/middleware/builder.rb, line 28 def initialize config, known_strategies: KNOWN_STRATEGIES @config = config @known_strategies = known_strategies end
Public Instance Methods
call()
click to toggle source
Builds the Strategies
object.
@return [Strategies] the strategies object.
# File lib/tenantify/middleware/builder.rb, line 36 def call Strategies.new(strategies) end
Private Instance Methods
strategies()
click to toggle source
# File lib/tenantify/middleware/builder.rb, line 44 def strategies strategies_config.map do |(name_or_class, strategy_config)| strategy_class_for(name_or_class).new(strategy_config) end end
strategies_config()
click to toggle source
# File lib/tenantify/middleware/builder.rb, line 58 def strategies_config config.strategies end
strategy_class_for(name_or_class)
click to toggle source
# File lib/tenantify/middleware/builder.rb, line 50 def strategy_class_for name_or_class case name_or_class when Class then name_or_class when Symbol, String then known_strategies.fetch(name_or_class.to_sym) else raise UnknownStrategyError.new(name_or_class.inspect) end end