Class: ActiveEncode::EngineAdapters::InlineAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/active_encode/engine_adapters/inline_adapter.rb

Instance Method Summary collapse

Instance Method Details

#cancel(encode) ⇒ Object


23
24
25
26
27
28
29
# File 'lib/active_encode/engine_adapters/inline_adapter.rb', line 23

def cancel(encode)
  inline_encode = self.class.encodes[encode.id]
  return if inline_encode.nil?
  inline_encode.state = :cancelled
  # cancel encode
  inline_encode
end

#create(encode) ⇒ Object


7
8
9
10
11
12
13
# File 'lib/active_encode/engine_adapters/inline_adapter.rb', line 7

def create(encode)
  encode.id = SecureRandom.uuid
  self.class.encodes[encode.id] = encode
  # start encode
  encode.state = :running
  encode
end

#find(id, _opts = {}) ⇒ Object


15
16
17
# File 'lib/active_encode/engine_adapters/inline_adapter.rb', line 15

def find(id, _opts = {})
  self.class.encodes[id]
end

#list(*_filters) ⇒ Object

Raises:

  • (NotImplementedError)

19
20
21
# File 'lib/active_encode/engine_adapters/inline_adapter.rb', line 19

def list(*_filters)
  raise NotImplementedError
end

#purge(encode) ⇒ Object


31
32
33
# File 'lib/active_encode/engine_adapters/inline_adapter.rb', line 31

def purge(encode)
  self.class.encodes.delete encode.id
end

#remove_output(encode, output_id) ⇒ Object


35
36
37
38
39
# File 'lib/active_encode/engine_adapters/inline_adapter.rb', line 35

def remove_output(encode, output_id)
  inline_encode = self.class.encodes[encode.id]
  return if inline_encode.nil?
  inline_encode.output.delete(inline_encode.output.find { |o| o[:id] == output_id })
end