Class: BulletmarkRepairer::Markers

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/bulletmark_repairer/markers.rb

Instance Method Summary collapse

Constructor Details

#initialize(notifications, controller:, action:) ⇒ Markers

Returns a new instance of Markers.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/bulletmark_repairer/markers.rb', line 11

def initialize(notifications, controller:, action:)
  @markers = {}
  notifications.collection.to_a.each do |notification|
    next unless notification.is_a?(::Bullet::Notification::NPlusOneQuery)

    base_class = notification.instance_variable_get(:@base_class)
    if @markers[base_class]
      @markers[base_class].add_association(notification)
    else
      @markers[base_class] = Marker.new(
        notification,
        controller: controller,
        action: action
      )
    end
  end
end