Class: Glib::JsonUi::ViewBuilder::View

Inherits:
JsonUiElement show all
Defined in:
app/helpers/glib/json_ui/view_builder.rb

Instance Attribute Summary

Attributes inherited from JsonUiElement

#json, #page

Instance Method Summary collapse

Methods inherited from JsonUiElement

#initialize, #parse

Constructor Details

This class inherits a constructor from Glib::JsonUi::JsonUiElement

Instance Method Details

#analytics(value) ⇒ Object



30
31
32
33
34
35
36
37
# File 'app/helpers/glib/json_ui/view_builder.rb', line 30

def analytics(value)
  if value.is_a?(String)
    @analyticsEnabled = true
    @analyticsId = value
  else
    @analyticsEnabled = value == true
  end
end

#createdObject

Override



40
41
42
43
44
45
46
47
48
# File 'app/helpers/glib/json_ui/view_builder.rb', line 40

def created
  if @analyticsEnabled
    context = page.context
    json.analytics do
      content = @analyticsId || (@text || @icon)&.gsub(/\s+/, '_')&.downcase || 'nil'
      json.namePrefix [context.controller_name, context.action_name, content].join('_')
    end
  end
end