Module: Subledger::Store::Api::Create
- Included in:
- Store
- Defined in:
- lib/subledger/store/api/roles/create.rb
Instance Method Summary collapse
Instance Method Details
#create(creatable) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/subledger/store/api/roles/create.rb', line 5 def create creatable unless creatable.id.nil? raise CreateError, 'cannot create an object with an :id' end path = Path.for_collection :anchor => creatable begin json_body = http.post do |req| req.url path req.body = creatable.post_hash end.body rescue Exception => e raise CreateError, "Cannot create #{creatable}: #{e}" end new_or_initialize json_body, creatable end |