Class: Glib::JsonUi::ActionBuilder::Windows::OpenWeb

Inherits:
Action show all
Defined in:
app/helpers/glib/json_ui/action_builder/windows.rb

Instance Attribute Summary

Attributes inherited from JsonUiElement

#json, #page

Instance Method Summary collapse

Methods inherited from JsonUiElement

#initialize, #props

Constructor Details

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

Instance Method Details

#url(value, options = {}) ⇒ Object

string :url



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

def url(value, options = {})
  regex = /\/.+\.json|format=json/

  if Rails.env.development? || Rails.env.test? && same_host?(value)
    raise "JSON url detected #{value}" if value.to_s.match?(regex)
  end

  if value.to_s.match?(regex) && Rails.env.production? && same_host?(value)
    Rollbar.error("JSON url detected #{value}")
    # value = value.gsub('.json', '')
  end

  instance_variable_set('@url', value) if options[:cache]
  json.set! 'url', value
end