Sha256: 563cc571a742e1dac338174629f16d4b6b155e51e11b1a5ab558990796935e4e

Contents?: true

Size: 773 Bytes

Versions: 12

Compression:

Stored size: 773 Bytes

Contents

module Hanami
  module Model
    # Conventional name for entities.
    #
    # Given a repository named <tt>SourceFileRepository</tt>, the associated
    # entity will be <tt>SourceFile</tt>.
    #
    # @since 0.7.0
    # @api private
    class EntityName
      # @since 0.7.0
      # @api private
      SUFFIX = /Repository\z/

      # @param name [Class,String] the class or its name
      # @return [String] the entity name
      #
      # @since 0.7.0
      # @api private
      def initialize(name)
        @name = name.sub(SUFFIX, '')
      end

      # @since 0.7.0
      # @api private
      def underscore
        Utils::String.underscore(@name).to_sym
      end

      # @since 0.7.0
      # @api private
      def to_s
        @name
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
hanami-model-1.3.0 lib/hanami/model/entity_name.rb
hanami-model-1.3.0.beta1 lib/hanami/model/entity_name.rb
hanami-model-1.2.0 lib/hanami/model/entity_name.rb
hanami-model-1.2.0.rc2 lib/hanami/model/entity_name.rb
hanami-model-1.2.0.rc1 lib/hanami/model/entity_name.rb
hanami-model-1.2.0.beta2 lib/hanami/model/entity_name.rb
hanami-model-1.2.0.beta1 lib/hanami/model/entity_name.rb
hanami-model-1.1.0 lib/hanami/model/entity_name.rb
hanami-model-1.1.0.rc1 lib/hanami/model/entity_name.rb
hanami-model-1.1.0.beta3 lib/hanami/model/entity_name.rb
hanami-model-1.1.0.beta2 lib/hanami/model/entity_name.rb
hanami-model-1.1.0.beta1 lib/hanami/model/entity_name.rb