Module: Subledger::Store::Api::CreateLine

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

Instance Method Summary collapse

Instance Method Details

#create_line(args) ⇒ Object



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

def create_line args
  begin
    line = args[:line]

    path = Path.for_entity( :anchor => line.journal_entry ) + '/create_line'

    json_body = http.post do |req|
                  req.url    path
                  req.body = line.post_hash
                end.body
  rescue Exception => e
    raise CreateLineError, "Cannot create #{line}: #{e}"
  end

  new_or_initialize json_body, line
end