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



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

def initialize(owner)
  @owner = owner
end

Instance Method Details

#failure(json) ⇒ Object



26
27
28
29
30
31
# File 'lib/sequencescape-api/resource/modifications.rb', line 26

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



22
23
24
# File 'lib/sequencescape-api/resource/modifications.rb', line 22

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