Class: Hanami::Model::EntityName Private

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

Conventional name for entities.

Given a repository named SourceFileRepository, the associated entity will be SourceFile.

Since:

  • 0.7.0

Direct Known Subclasses

RelationName

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.7.0

/Repository\z/.freeze

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ String

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 the entity name.

Parameters:

  • name (Class, String)

    the class or its name

Since:

  • 0.7.0



22
23
24
# File 'lib/hanami/model/entity_name.rb', line 22

def initialize(name)
  @name = name.sub(SUFFIX, "")
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.7.0



34
35
36
# File 'lib/hanami/model/entity_name.rb', line 34

def to_s
  @name
end

#underscoreObject

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.7.0



28
29
30
# File 'lib/hanami/model/entity_name.rb', line 28

def underscore
  Utils::String.underscore(@name).to_sym
end