Class: Glib::JsonUi::ActionBuilder::Action

Inherits:
JsonUiElement show all
Defined in:
app/helpers/glib/json_ui/action_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



9
10
11
12
13
14
15
16
# File 'app/helpers/glib/json_ui/action_builder.rb', line 9

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

#createdObject

Override



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/helpers/glib/json_ui/action_builder.rb', line 19

def created
  if @analyticsEnabled
    suffix = @analyticsId
    # TODO: recognize_path() needs `method` as a second argument for POST request
    if suffix.nil? && @url && (route = Rails.application.routes.recognize_path(@url))
      suffix = "#{route[:controller]}_#{route[:action]}"
    end

    if suffix
      json.analytics do
        json.track :event
        json.nameSuffix suffix
      end
    end

  end
end