Class: ActiveEncode::EngineAdapters::TestAdapter

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

Instance Method Summary collapse

Constructor Details

#initializeTestAdapter

Returns a new instance of TestAdapter.



4
5
6
# File 'lib/active_encode/engine_adapters/test_adapter.rb', line 4

def initialize
  @encodes = {}
end

Instance Method Details

#cancel(id) ⇒ Object



25
26
27
28
29
30
# File 'lib/active_encode/engine_adapters/test_adapter.rb', line 25

def cancel(id)
  new_encode = @encodes[id]
  new_encode.state = :cancelled
  new_encode.updated_at = Time.now
  new_encode
end

#create(input_url, options = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/active_encode/engine_adapters/test_adapter.rb', line 8

def create(input_url, options = {})
  new_encode = ActiveEncode::Base.new(input_url, options)
  new_encode.id = SecureRandom.uuid
  new_encode.state = :running
  new_encode.created_at = Time.now
  new_encode.updated_at = Time.now
  @encodes[new_encode.id] = new_encode
  new_encode
end

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



18
19
20
21
22
23
# File 'lib/active_encode/engine_adapters/test_adapter.rb', line 18

def find(id, _opts = {})
  new_encode = @encodes[id]
  # Update the updated_at time to simulate changes
  new_encode.updated_at = Time.now
  new_encode
end

#list(*_filters) ⇒ Object

Raises:

  • (NotImplementedError)


32
33
34
# File 'lib/active_encode/engine_adapters/test_adapter.rb', line 32

def list(*_filters)
  raise NotImplementedError
end

#purge(encode) ⇒ Object



36
37
38
# File 'lib/active_encode/engine_adapters/test_adapter.rb', line 36

def purge(encode)
  @encodes.delete(encode.id)
end

#remove_output(_encode, _output_id) ⇒ Object

Raises:

  • (NotImplementedError)


40
41
42
# File 'lib/active_encode/engine_adapters/test_adapter.rb', line 40

def remove_output(_encode, _output_id)
  raise NotImplementedError
end