Class: Hanami::Validations::Namespace Private

Inherits:
Object
  • Object
show all
Defined in:
lib/hanami/validations/namespace.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Validations message namespace.

For a given ‘FooValidator` class, it will look for I18n messages within the `foo` group.

Since:

  • 0.6.0

Constant Summary collapse

SUFFIX =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Since:

  • 0.6.0

"Validator"
SUFFIX_REPLACEMENT =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Since:

  • 0.6.0

""
RUBY_NAMESPACE_SEPARATOR =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Since:

  • 0.6.0

"/"
RUBY_NAMESPACE_REPLACEMENT =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Since:

  • 0.6.0

"."

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Namespace

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Namespace.

Since:

  • 0.6.0



42
43
44
# File 'lib/hanami/validations/namespace.rb', line 42

def initialize(name)
  @name = name
end

Class Method Details

.new(name, klass) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.6.0



33
34
35
36
37
38
# File 'lib/hanami/validations/namespace.rb', line 33

def self.new(name, klass)
  result = name || klass.name
  return nil if result.nil?

  super(result)
end

Instance Method Details

#to_sObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.6.0



48
49
50
# File 'lib/hanami/validations/namespace.rb', line 48

def to_s
  underscored_name.gsub(RUBY_NAMESPACE_SEPARATOR, RUBY_NAMESPACE_REPLACEMENT)
end