Class: NxtErrorRegistry::Registry

Inherits:
Object
  • Object
show all
Defined in:
lib/nxt_error_registry/registry.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRegistry



10
11
12
# File 'lib/nxt_error_registry/registry.rb', line 10

def initialize
  @store = {}
end

Instance Attribute Details

#storeObject (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

.instanceObject



3
4
5
# File 'lib/nxt_error_registry/registry.rb', line 3

def self.instance
  @instance ||= send(:new)
end

Instance Method Details

#codesObject



23
24
25
# File 'lib/nxt_error_registry/registry.rb', line 23

def codes
  flat.map { |entry| entry.fetch(:code) }
end

#duplicated_codesObject



34
35
36
# File 'lib/nxt_error_registry/registry.rb', line 34

def duplicated_codes
  entries_by_codes.select { |_, v| v.size > 1 }
end

#entries_by_codesObject



27
28
29
30
31
32
# File 'lib/nxt_error_registry/registry.rb', line 27

def entries_by_codes
  flat.each_with_object({}) do |entry, acc|
    code = entry.fetch(:code)
    (acc[code] ||= []) << entry
  end
end

#flatObject



19
20
21
# File 'lib/nxt_error_registry/registry.rb', line 19

def flat
  values.map(&:values).flatten
end