class NxtErrorRegistry::Registry

Attributes

store[R]

Public Class Methods

instance() click to toggle source
# File lib/nxt_error_registry/registry.rb, line 3
def self.instance
  @instance ||= send(:new)
end
new() click to toggle source

Usually we don't want this to be initialized other than through instance

# File lib/nxt_error_registry/registry.rb, line 10
def initialize
  @store = { }
end

Public Instance Methods

codes() click to toggle source
# File lib/nxt_error_registry/registry.rb, line 23
def codes
  flat.map { |entry| entry.fetch(:code) }
end
duplicated_codes() click to toggle source
# File lib/nxt_error_registry/registry.rb, line 35
def duplicated_codes
  entries_by_codes.select { |_, v| v.size > 1 }
end
entries_by_codes() click to toggle source
# 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() click to toggle source
# File lib/nxt_error_registry/registry.rb, line 19
def flat
  values.map(&:values).flatten
end