Class: Layered::Ui::PopoverHelper::PopoverBuilder

Inherits:
Object
  • Object
show all
Defined in:
app/helpers/layered/ui/popover_helper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(view, id:) ⇒ PopoverBuilder

Returns a new instance of PopoverBuilder.



50
51
52
53
# File 'app/helpers/layered/ui/popover_helper.rb', line 50

def initialize(view, id:)
  @view = view
  @id = id
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



48
49
50
# File 'app/helpers/layered/ui/popover_helper.rb', line 48

def id
  @id
end

#trigger_htmlObject (readonly)

Returns the value of attribute trigger_html.



48
49
50
# File 'app/helpers/layered/ui/popover_helper.rb', line 48

def trigger_html
  @trigger_html
end

Instance Method Details

#trigger(**options, &block) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
# File 'app/helpers/layered/ui/popover_helper.rb', line 55

def trigger(**options, &block)
  options = options.deep_dup
  options[:type] ||= "button"
  options[:popovertarget] = id
  data = options[:data] || {}
  data[:"l-ui--popover-target"] = "trigger"
  options[:data] = data
  content = @view.capture(&block)
  @trigger_html = @view.tag.button(content, **options)
  nil
end