Sha256: 72c13d6e3ed47fbdb162bbd199721311e1bc810dbd753e8430d3d388fc271bf7

Contents?: true

Size: 719 Bytes

Versions: 17

Compression:

Stored size: 719 Bytes

Contents

module Superstore
  module BelongsTo
    class Reflection
      attr_reader :model, :name, :options
      def initialize(model, name, options)
        @model, @name, @options = model, name, options
      end

      def instance_variable_name
        "@#{name}"
      end

      def foreign_key
        options[:foreign_key] || "#{name}_id"
      end

      def primary_key
        options[:primary_key] || "id"
      end

      def default_primary_key?
        primary_key == "id"
      end

      def polymorphic_column
        "#{name}_type"
      end

      def polymorphic?
        options[:polymorphic]
      end

      def class_name
        options[:class_name] || name.to_s.camelize
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
superstore-1.2.0 lib/superstore/belongs_to/reflection.rb
superstore-1.1.4 lib/superstore/belongs_to/reflection.rb
superstore-1.1.3 lib/superstore/belongs_to/reflection.rb
superstore-1.1.2 lib/superstore/belongs_to/reflection.rb
superstore-1.1.1 lib/superstore/belongs_to/reflection.rb
superstore-1.1.0 lib/superstore/belongs_to/reflection.rb
superstore-1.0.12 lib/superstore/belongs_to/reflection.rb
superstore-1.0.11 lib/superstore/belongs_to/reflection.rb
superstore-1.0.10 lib/superstore/belongs_to/reflection.rb
superstore-1.0.9 lib/superstore/belongs_to/reflection.rb
superstore-1.0.8 lib/superstore/belongs_to/reflection.rb
superstore-1.0.7 lib/superstore/belongs_to/reflection.rb
superstore-1.0.6 lib/superstore/belongs_to/reflection.rb
superstore-1.0.5 lib/superstore/belongs_to/reflection.rb
superstore-1.0.4 lib/superstore/belongs_to/reflection.rb
superstore-1.0.3 lib/superstore/belongs_to/reflection.rb
superstore-1.0.2 lib/superstore/belongs_to/reflection.rb