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/

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



20
21
22
# File 'lib/hanami/model/entity_name.rb', line 20

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



32
33
34
# File 'lib/hanami/model/entity_name.rb', line 32

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



26
27
28
# File 'lib/hanami/model/entity_name.rb', line 26

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