Class: Sequencescape::Api::ModifyingHandler

Inherits:
Object
  • Object
show all
Includes:
BasicErrorHandling
Defined in:
lib/sequencescape-api/resource/modifications.rb

Instance Method Summary collapse

Methods included from BasicErrorHandling

#missing, #redirection, #unauthenticated

Constructor Details

#initialize(owner) ⇒ ModifyingHandler

Returns a new instance of ModifyingHandler.



4
5
6
# File 'lib/sequencescape-api/resource/modifications.rb', line 4

def initialize(owner)
  @owner = owner
end

Instance Method Details

#failure(json) ⇒ Object



29
30
31
32
33
34
# File 'lib/sequencescape-api/resource/modifications.rb', line 29

def failure(json)
  Array(json.fetch('content', [])).map(&method(:error))
  Array(json.fetch('general', [])).map(&method(:object_error))

  raise Sequencescape::Api::ResourceInvalid, @owner
end

#success(json) ⇒ Object



25
26
27
# File 'lib/sequencescape-api/resource/modifications.rb', line 25

def success(json)
  update_from_json(json, true)
end