Sha256: 400da9dc2205b90ad8d36d972b4dbf823b7ddcbf7348ab3f3e5c7b0b5fb37e41

Contents?: true

Size: 496 Bytes

Versions: 18

Compression:

Stored size: 496 Bytes

Contents

# frozen_string_literal: true

class Object
  def bullet_key
    "#{self.class}:#{bullet_primary_key_value}"
  end

  def bullet_primary_key_value
    return if respond_to?(:persisted?) && !persisted?

    if self.class.respond_to?(:primary_keys) && self.class.primary_keys
      self.class.primary_keys.map { |primary_key| send primary_key }.join(',')
    elsif self.class.respond_to?(:primary_key) && self.class.primary_key
      send self.class.primary_key
    else
      id
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
bullet-7.1.0 lib/bullet/ext/object.rb
bullet-7.0.7 lib/bullet/ext/object.rb
bullet-7.0.6 lib/bullet/ext/object.rb
bullet-7.0.5 lib/bullet/ext/object.rb
bullet-7.0.4 lib/bullet/ext/object.rb
bullet-7.0.3 lib/bullet/ext/object.rb
bullet-7.0.2 lib/bullet/ext/object.rb
bullet-7.0.1 lib/bullet/ext/object.rb
bullet-7.0.0 lib/bullet/ext/object.rb
bullet-6.1.5 lib/bullet/ext/object.rb
bullet-6.1.4 lib/bullet/ext/object.rb
bullet-6.1.3 lib/bullet/ext/object.rb
bullet-6.1.2 lib/bullet/ext/object.rb
bullet-6.1.1 lib/bullet/ext/object.rb
bullet-6.1.0 lib/bullet/ext/object.rb
bullet-6.0.2 lib/bullet/ext/object.rb
bullet-6.0.1 lib/bullet/ext/object.rb
bullet-6.0.0 lib/bullet/ext/object.rb