Module: Styxie::Initializer

Defined in:
lib/styxie/initializer.rb

Instance Method Summary collapse

Instance Method Details

#styxie_classObject



35
36
37
# File 'lib/styxie/initializer.rb', line 35

def styxie_class
  controller_path.tr('/', '_').camelize
end

#styxie_configurationObject



31
32
33
# File 'lib/styxie/initializer.rb', line 31

def styxie_configuration
  @styxie_initialize_with ||= {}
end

#styxie_initialize(klass: styxie_class, method: action_name, data: styxie_configuration) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/styxie/initializer.rb', line 8

def styxie_initialize(klass: styxie_class, method: action_name, data: styxie_configuration)
  json = data.to_json
  result = "<script type=\"text/javascript\">\n//<![CDATA[\n  if (typeof Styxie === 'undefined' || Styxie === null) {\nStyxie = {}\n  }\n  if (Styxie.applyInitializer) {\nStyxie.applyInitializer('\#{klass}', '\#{method}', \#{json});\n  } else {\nif (Styxie.initQueue == null) {\n  Styxie.initQueue = []\n}\nStyxie.initQueue.push(['\#{klass}', '\#{method}', \#{json}]);\n  }\n//]]>\n</script>\n  CODE\n\n  result.html_safe\nend\n"

#styxie_initialize_with(data, cfg: styxie_configuration) ⇒ Object



4
5
6
# File 'lib/styxie/initializer.rb', line 4

def styxie_initialize_with(data, cfg: styxie_configuration)
  cfg.merge! data
end