Module: Subledger::Store::Api::Update

Included in:
Store
Defined in:
lib/subledger/store/api/roles/update.rb

Instance Method Summary collapse

Instance Method Details

#update(updatable) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/subledger/store/api/roles/update.rb', line 5

def update updatable
  path = Path.for_entity :anchor => updatable

  begin
    json_body = http.patch do |req|
                  req.url    path
                  req.body = updatable.patch_hash
                end.body
  rescue UpdateConflictError => e
    raise e
  rescue Exception => e
    raise UpdateError, "Cannot update #{updatable}: #{e}"
  end

  new_or_initialize json_body, updatable
end