Module: Fie::Manipulator

Defined in:
lib/fie/manipulator.rb

Instance Method Summary collapse

Instance Method Details

#commander_exists?Boolean

Returns:

  • (Boolean)


30
31
32
33
# File 'lib/fie/manipulator.rb', line 30

def commander_exists?
  commander_name = Commander.commander_name(@fie_connection_uuid)
  !redis.get(commander_name).nil?
end

#execute_js_function(name, *arguments) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/fie/manipulator.rb', line 16

def execute_js_function(name, *arguments)
  commander_name = Commander.commander_name(@fie_connection_uuid)

  if commander_exists?
    ActionCable.server.broadcast \
      commander_name,
      command: 'execute_function',
      parameters: {
        name: name,
        arguments: arguments
      }
  end
end

#stateObject



6
7
8
9
10
11
12
13
14
# File 'lib/fie/manipulator.rb', line 6

def state
  commander_name = Commander.commander_name(@fie_connection_uuid)

  if commander_exists?
    Marshal.load redis.get(commander_name)
  else
    raise Fie::CommanderClosed, commander_name
  end
end