Sha256: b6025b13930436604f447957d77d8948d731ef589b278a919a2f83dacc67cd2b

Contents?: true

Size: 675 Bytes

Versions: 8

Compression:

Stored size: 675 Bytes

Contents

module ROM
  module Plugins
    module Relation
      module KeyInference
        # Infer foreign_key name for this relation
        #
        # TODO: this should be configurable and handled by an injected policy
        #
        # @return [Symbol]
        #
        # @api private
        def foreign_key
          :"#{Inflector.singularize(name)}_id"
        end

        # Return base name which defaults to name attribute
        #
        # @return [Symbol]
        #
        # @api private
        def base_name
          name
        end
      end
    end
  end
end

ROM.plugins do
  register :key_inference, ROM::Plugins::Relation::KeyInference, type: :relation
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
rom-repository-0.2.0 lib/rom/plugins/relation/key_inference.rb
rom-1.0.0 lib/rom/plugins/relation/key_inference.rb
rom-repository-0.2.0.rc1 lib/rom/plugins/relation/key_inference.rb
rom-1.0.0.rc1 lib/rom/plugins/relation/key_inference.rb
rom-1.0.0.beta2 lib/rom/plugins/relation/key_inference.rb
rom-repository-0.2.0.beta1 lib/rom/plugins/relation/key_inference.rb
rom-1.0.0.beta1 lib/rom/plugins/relation/key_inference.rb
rom-repository-0.1.0 lib/rom/plugins/relation/key_inference.rb