Class: Hanami::V1::Validations::Namespace Private

Inherits:
Object
  • Object
show all
Defined in:
lib/hanami/v1/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



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

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



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

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



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

def to_s
  underscored_name.gsub(RUBY_NAMESPACE_SEPARATOR, RUBY_NAMESPACE_REPLACEMENT)
end