Module: LightServiceExt::ApplicationContract::ClassMethods

Defined in:
lib/light-service-ext/application_contract.rb

Instance Method Summary collapse

Instance Method Details

#keysObject



27
28
29
30
31
# File 'lib/light-service-ext/application_contract.rb', line 27

def keys
  return [] if schema.nil?

  schema&.rules&.keys || []
end

#t(key, base_path: "errors", **opts) ⇒ Object



35
36
37
38
39
40
41
42
43
# File 'lib/light-service-ext/application_contract.rb', line 35

def t(key, base_path: "errors", **opts)
  scope = opts[:scope] || ""
  path = [base_path, scope, key.to_s].join(".")

  message = messages.translate(path)
  return message if message.exclude?("%{")

  (message % opts.except(:scope))
end