Sha256: fc377df0bb53757b31a896582fb858f8ef4f80ec076fe39e28bfd98484931f68

Contents?: true

Size: 604 Bytes

Versions: 6

Compression:

Stored size: 604 Bytes

Contents

require_relative 'entity_name'
require 'hanami/utils/string'

module Hanami
  module Model
    # Conventional name for relations.
    #
    # Given a repository named <tt>SourceFileRepository</tt>, the associated
    # relation will be <tt>:source_files</tt>.
    #
    # @since 0.7.0
    # @api private
    class RelationName < EntityName
      # @param name [Class,String] the class or its name
      # @return [Symbol] the relation name
      #
      # @since 0.7.0
      # @api private
      def self.new(name)
        Utils::String.new(super).underscore.pluralize.to_sym
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
hanami-model-1.0.0 lib/hanami/model/relation_name.rb
hanami-model-1.0.0.rc1 lib/hanami/model/relation_name.rb
hanami-model-1.0.0.beta3 lib/hanami/model/relation_name.rb
hanami-model-1.0.0.beta2 lib/hanami/model/relation_name.rb
hanami-model-1.0.0.beta1 lib/hanami/model/relation_name.rb
hanami-model-0.7.0 lib/hanami/model/relation_name.rb