Sha256: e31bda1a1d76d0e73812facef03948fd2583eb4c83132a91db3915f312e43e6f
Contents?: true
Size: 1.94 KB
Versions: 1
Compression:
Stored size: 1.94 KB
Contents
require 'roar/representer/feature/transport' module Roar # Gives HTTP-power to representers where those can automatically serialize, send, process and deserialize HTTP-requests. module Representer module Feature module HttpVerbs def self.included(base) base.extend ClassMethods end module ClassMethods include Transport def get(url, format) # TODO: test me! #url = resource_base + variable_path.to_s representation = get_uri(url, format).body deserialize(representation) end def post(url, body, format) representation = post_uri(url, body, format).body deserialize(representation) end def put(url, body, format) representation = put_uri(url, body, format).body deserialize(representation) end end def post(url, format) self.class.post(url, serialize, format) end def post!(*args) rep = post(*args) # TODO: make this better. self.class.representable_attrs.each do |definition| send(definition.setter, rep.public_send(definition.getter)) end # TODO: this sucks. do this with #properties and #replace_properties. end def get!(url, format) # FIXME: abstract to #replace_properties rep = self.class.get(url, format) # TODO: where's the format? why do we need class here? self.class.representable_attrs.each do |definition| send(definition.setter, rep.public_send(definition.getter)) end # TODO: this sucks. do this with #properties and #replace_properties. end def put(url, format) self.class.put(url, serialize, format) end # TODO: implement delete, patch. end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
roar-0.8.2 | lib/roar/representer/feature/http_verbs.rb |