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'.freeze
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

''.freeze
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

'/'.freeze
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

'.'.freeze

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



40
41
42
# File 'lib/hanami/validations/namespace.rb', line 40

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



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

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



46
47
48
# File 'lib/hanami/validations/namespace.rb', line 46

def to_s
  underscored_name.gsub(RUBY_NAMESPACE_SEPARATOR, RUBY_NAMESPACE_REPLACEMENT)
end