Class: Decidim::SpamSignal::Scans::ScansRepository
- Inherits:
-
Object
- Object
- Decidim::SpamSignal::Scans::ScansRepository
- Includes:
- Singleton
- Defined in:
- lib/decidim/spam_signal/scans/scans_repository.rb
Overview
Strategies repository
Instance Attribute Summary collapse
-
#strategies ⇒ Object
readonly
Returns the value of attribute strategies.
Instance Method Summary collapse
- #form_for(strategy) ⇒ Object
-
#initialize ⇒ ScansRepository
constructor
A new instance of ScansRepository.
- #register(strategy, command_klass) ⇒ Object
- #strategy(strategy) ⇒ Object
- #unset_strategy(strategy) ⇒ Object
Constructor Details
#initialize ⇒ ScansRepository
Returns a new instance of ScansRepository.
14 15 16 |
# File 'lib/decidim/spam_signal/scans/scans_repository.rb', line 14 def initialize @_strategies = {} end |
Instance Attribute Details
#strategies ⇒ Object (readonly)
Returns the value of attribute strategies.
12 13 14 |
# File 'lib/decidim/spam_signal/scans/scans_repository.rb', line 12 def strategies @strategies end |
Instance Method Details
#form_for(strategy) ⇒ Object
32 33 34 |
# File 'lib/decidim/spam_signal/scans/scans_repository.rb', line 32 def form_for(strategy) strategy(strategy).form end |
#register(strategy, command_klass) ⇒ Object
18 19 20 |
# File 'lib/decidim/spam_signal/scans/scans_repository.rb', line 18 def register(strategy, command_klass) @_strategies[strategy.to_sym] = command_klass end |
#strategy(strategy) ⇒ Object
36 37 38 39 40 |
# File 'lib/decidim/spam_signal/scans/scans_repository.rb', line 36 def strategy(strategy) key = "#{strategy}".to_sym return @_strategies[key] if @_strategies.key? key nil end |
#unset_strategy(strategy) ⇒ Object
22 23 24 25 26 |
# File 'lib/decidim/spam_signal/scans/scans_repository.rb', line 22 def unset_strategy(strategy) key = strategy.to_sym raise Error, "Cop's Strategy #{strategy} does not exists" unless @_strategies.key? key @_strategies.except!(key) end |