Module: Subledger::Store::Api::FirstAndLastLine

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

Instance Method Summary collapse

Instance Method Details

#first_and_last_line(args) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/subledger/store/api/roles/first_and_last_line.rb', line 6

def first_and_last_line args
  anchor = args[:account]
  client = anchor.client

  path = Path.for_entity( :anchor => anchor ) + '/first_and_last_line'

  klass = anchor.class

  begin
    collection = parse_json http.get( path ).body
  rescue Exception => e
    raise FirstAndLastLineError, "Cannot get first and last line: #{e}"
  end

  key = collection.keys.first

  collection[key].collect do |response_hash|
    args = Rest.to_args response_hash, client

    client.send key, args
  end
end