Class: Locomotive::Steam::ActionService

Inherits:
Object
  • Object
show all
Defined in:
lib/locomotive/steam/services/action_service.rb

Constant Summary collapse

BUILT_IN_FUNCTIONS =
%w(
getProp
setProp
getSessionProp
setSessionProp
sendEmail
allEntries
findEntry
createEntry
updateEntry)

Instance Method Summary collapse

Instance Method Details

#run(script, params = {}, liquid_context) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/locomotive/steam/services/action_service.rb', line 27

def run(script, params = {}, liquid_context)
  context = Duktape::Context.new

  define_built_in_functions(context, liquid_context)

  script = "    function locomotiveAction(site, params) {\n      \#{script}\n    }\n  JS\n\n  # puts script.inspect # DEBUG\n\n  context.exec_string script\n\n  context.call_prop('locomotiveAction', site.as_json, params)\nend\n"