Class: Layered::Ui::TagHelper::TagBuilder

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(view) ⇒ TagBuilder

Returns a new instance of TagBuilder.



76
77
78
79
# File 'app/helpers/layered/ui/tag_helper.rb', line 76

def initialize(view)
  @view = view
  @segments = []
end

Instance Attribute Details

#popover_alignObject (readonly)

Returns the value of attribute popover_align.



74
75
76
# File 'app/helpers/layered/ui/tag_helper.rb', line 74

def popover_align
  @popover_align
end

#popover_bodyObject (readonly)

Returns the value of attribute popover_body.



74
75
76
# File 'app/helpers/layered/ui/tag_helper.rb', line 74

def popover_body
  @popover_body
end

#popover_idObject (readonly)

Returns the value of attribute popover_id.



74
75
76
# File 'app/helpers/layered/ui/tag_helper.rb', line 74

def popover_id
  @popover_id
end

#popover_openObject (readonly)

Returns the value of attribute popover_open.



74
75
76
# File 'app/helpers/layered/ui/tag_helper.rb', line 74

def popover_open
  @popover_open
end

#popover_placementObject (readonly)

Returns the value of attribute popover_placement.



74
75
76
# File 'app/helpers/layered/ui/tag_helper.rb', line 74

def popover_placement
  @popover_placement
end

#segmentsObject (readonly)

Returns the value of attribute segments.



74
75
76
# File 'app/helpers/layered/ui/tag_helper.rb', line 74

def segments
  @segments
end

Instance Method Details

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



87
88
89
90
91
# File 'app/helpers/layered/ui/tag_helper.rb', line 87

def button(**options, &block)
  content = block ? @view.capture(&block) : nil
  @segments << { kind: :button, content: content, options: options }
  nil
end


93
94
95
96
97
# File 'app/helpers/layered/ui/tag_helper.rb', line 93

def link(url, **options, &block)
  content = block ? @view.capture(&block) : nil
  @segments << { kind: :link, url: url, content: content, options: options }
  nil
end

#popover(id: nil, placement: :bottom, align: :start, open: false, &block) ⇒ Object



105
106
107
108
109
110
111
112
# File 'app/helpers/layered/ui/tag_helper.rb', line 105

def popover(id: nil, placement: :bottom, align: :start, open: false, &block)
  @popover_id = id || "l-ui-tag-popover-#{SecureRandom.hex(4)}"
  @popover_placement = placement
  @popover_align = align
  @popover_open = open
  @popover_body = @view.capture(&block)
  nil
end

#popover?Boolean

Returns:

  • (Boolean)


114
115
116
# File 'app/helpers/layered/ui/tag_helper.rb', line 114

def popover?
  !@popover_id.nil?
end

#remove(url = nil, **options, &block) ⇒ Object



99
100
101
102
103
# File 'app/helpers/layered/ui/tag_helper.rb', line 99

def remove(url = nil, **options, &block)
  content = block ? @view.capture(&block) : nil
  @segments << { kind: :remove, url: url, content: content, options: options }
  nil
end

#text(content = nil, **options, &block) ⇒ Object



81
82
83
84
85
# File 'app/helpers/layered/ui/tag_helper.rb', line 81

def text(content = nil, **options, &block)
  content = @view.capture(&block) if block
  @segments << { kind: :text, content: content, options: options }
  nil
end