Sha256: 2f409964b203b1c334bf2f8d02bc3f5e986a53a98a5f6c5a5399290e43945395
Contents?: true
Size: 778 Bytes
Versions: 1
Compression:
Stored size: 778 Bytes
Contents
module Panda module Builders def self.included(base) base.extend(CreateBuilder) base.extend(DeleteBuilder) end module CreateBuilder def create(attributes) if attr_id=(attributes[:id] || attributes['id']) raise "Can't create attribute. Already have an id=#{attr_id}" end response = connection.post(full_object_url(many_path), attributes) Panda::const_get("#{end_class_name}").new(response) end def create!(attributes) create(attributes) || raise(self.error.first.to_s) end end module DeleteBuilder def delete(id) response = connection.delete(full_object_url(object_url(one_path,{:id =>id}))) response['deleted'] == 'ok' end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
faraday-panda-1.1.0 | lib/panda/modules/builders.rb |