Class: Evilution::Reporter::Suggestion::Registry
- Inherits:
-
Object
- Object
- Evilution::Reporter::Suggestion::Registry
- Defined in:
- lib/evilution/reporter/suggestion/registry.rb
Class Method Summary collapse
Instance Method Summary collapse
- #concrete(operator_name, integration:) ⇒ Object
- #each_generic_operator ⇒ Object
- #generic(operator_name) ⇒ Object
-
#initialize ⇒ Registry
constructor
A new instance of Registry.
- #register_concrete(operator_name, integration:, block:) ⇒ Object
- #register_generic(operator_name, text) ⇒ Object
Constructor Details
#initialize ⇒ Registry
Returns a new instance of Registry.
32 33 34 35 |
# File 'lib/evilution/reporter/suggestion/registry.rb', line 32 def initialize @generic = {} @concrete = Hash.new { |h, k| h[k] = {} } end |
Class Method Details
.default ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/evilution/reporter/suggestion/registry.rb', line 7 def self.default return @default if @default require_relative "templates/generic" require_relative "templates/rspec" require_relative "templates/minitest" registry = new Evilution::Reporter::Suggestion::Templates::Generic::GENERIC_ENTRIES.each do |op, text| registry.register_generic(op, text) end Evilution::Reporter::Suggestion::Templates::Rspec::RSPEC_ENTRIES.each do |op, blk| registry.register_concrete(op, integration: :rspec, block: blk) end Evilution::Reporter::Suggestion::Templates::Minitest::MINITEST_ENTRIES.each do |op, blk| registry.register_concrete(op, integration: :minitest, block: blk) end @default = registry end |
.reset! ⇒ Object
28 29 30 |
# File 'lib/evilution/reporter/suggestion/registry.rb', line 28 def self.reset! @default = nil end |
Instance Method Details
#concrete(operator_name, integration:) ⇒ Object
51 52 53 |
# File 'lib/evilution/reporter/suggestion/registry.rb', line 51 def concrete(operator_name, integration:) @concrete.fetch(integration, {})[operator_name] end |
#each_generic_operator ⇒ Object
55 56 57 58 59 |
# File 'lib/evilution/reporter/suggestion/registry.rb', line 55 def each_generic_operator(&) return @generic.each_key unless block_given? @generic.each_key(&) end |
#generic(operator_name) ⇒ Object
47 48 49 |
# File 'lib/evilution/reporter/suggestion/registry.rb', line 47 def generic(operator_name) @generic[operator_name] end |
#register_concrete(operator_name, integration:, block:) ⇒ Object
42 43 44 45 |
# File 'lib/evilution/reporter/suggestion/registry.rb', line 42 def register_concrete(operator_name, integration:, block:) @concrete[integration][operator_name] = block self end |
#register_generic(operator_name, text) ⇒ Object
37 38 39 40 |
# File 'lib/evilution/reporter/suggestion/registry.rb', line 37 def register_generic(operator_name, text) @generic[operator_name] = text self end |