Module: NetStatus

Defined in:
lib/net_status.rb,
lib/net_status/hash.rb,
lib/net_status/version.rb,
lib/net_status/exception.rb

Defined Under Namespace

Classes: Exception, Hash

Constant Summary collapse

VERSION =
'0.2.0'

Class Method Summary collapse

Class Method Details

.normalize(net_status, context: nil) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/net_status.rb', line 7

def self.normalize(net_status, context: nil)
  code = net_status[:code]
  code ||= net_status[:error] if net_status.include? :error
  net_status[:data] ||= {}
  message = (I18n.t [:net_status, context, code].join('.'), [:net_status, code].join('.'), **net_status[:data], raise: true rescue nil)
  net_status[:message] = message if message
  net_status
end