Class: Coupdoeil::Tag

Inherits:
Object
  • Object
show all
Defined in:
app/models/coupdoeil/tag.rb

Instance Method Summary collapse

Constructor Details

#initialize(popover:, popover_options:, attributes:) ⇒ Tag

Returns a new instance of Tag.



7
8
9
10
11
12
# File 'app/models/coupdoeil/tag.rb', line 7

def initialize(popover:, popover_options:, attributes:)
  @popover_setup = popover
  @popover_setup.with_options(popover_options) if popover_options
  @attributes = attributes
  @popover_setup.options.validate!
end

Instance Method Details

#render_in(view_context, &block) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/models/coupdoeil/tag.rb', line 14

def render_in(view_context, &block)
  ActiveSupport::Notifications.instrument("render_tag.coupdoeil") do
    content = view_context.capture(&block) if block_given?
    view_context.("coup-doeil", **tag_attributes) do
      if popover_options.preload?
        view_context.tag.template(view_context.render(popover_setup), class: "popover-content") + content
      else
        content
      end
    end
  end
end