Class: Intercept::StrategyBuilder
- Inherits:
-
Object
- Object
- Intercept::StrategyBuilder
- Defined in:
- lib/intercept/strategy_builder.rb
Class Method Summary collapse
Class Method Details
.from_hash(strategy) ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/intercept/strategy_builder.rb', line 5 def self.from_hash(strategy) return unless strategy strategy_class = get_class(strategy[:name]) if fallback = Intercept::StrategyBuilder.from_hash(strategy[:fallback]) strategy_class.new(strategy[:args], fallback) else strategy_class.new(strategy[:args]) end end |
.get_class(symbol) ⇒ Object
16 17 18 |
# File 'lib/intercept/strategy_builder.rb', line 16 def self.get_class(symbol) Object.const_get "Intercept::Strategy::#{symbol.to_s.split('_').map{ |w| w.capitalize }.join}" end |