Class: NxtErrorRegistry::Registry
- Inherits:
-
Object
- Object
- NxtErrorRegistry::Registry
- Defined in:
- lib/nxt_error_registry/registry.rb
Instance Attribute Summary collapse
-
#store ⇒ Object
readonly
Returns the value of attribute store.
Class Method Summary collapse
Instance Method Summary collapse
- #codes ⇒ Object
- #duplicated_codes ⇒ Object
- #entries_by_codes ⇒ Object
- #flat ⇒ Object
-
#initialize ⇒ Registry
constructor
A new instance of Registry.
Constructor Details
#initialize ⇒ Registry
Returns a new instance of Registry.
10 11 12 |
# File 'lib/nxt_error_registry/registry.rb', line 10 def initialize @store = { } end |
Instance Attribute Details
#store ⇒ Object (readonly)
Returns the value of attribute store.
14 15 16 |
# File 'lib/nxt_error_registry/registry.rb', line 14 def store @store end |
Class Method Details
.instance ⇒ Object
3 4 5 |
# File 'lib/nxt_error_registry/registry.rb', line 3 def self.instance @instance ||= send(:new) end |
Instance Method Details
#codes ⇒ Object
23 24 25 |
# File 'lib/nxt_error_registry/registry.rb', line 23 def codes flat.map { |entry| entry.fetch(:code) } end |
#duplicated_codes ⇒ Object
35 36 37 |
# File 'lib/nxt_error_registry/registry.rb', line 35 def duplicated_codes entries_by_codes.select { |_, v| v.size > 1 } end |
#entries_by_codes ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/nxt_error_registry/registry.rb', line 27 def entries_by_codes flat.inject({}) do |acc, entry| code = entry.fetch(:code) (acc[code] ||= []) << entry acc end end |
#flat ⇒ Object
19 20 21 |
# File 'lib/nxt_error_registry/registry.rb', line 19 def flat values.map(&:values).flatten end |