dm-restful-adapter 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,18 +4,18 @@ module Restful
4
4
  def create(resources)
5
5
  resources.each { |resource|
6
6
  dirty_attributes = resource.dirty_attributes.inject({}) { |hash, (k,v)| hash.update(k.name => v) }
7
- resource.attributes = Request.post(resource.model.name, dirty_attributes)
7
+ resource.attributes = Request.post(resource.model.storage_name, dirty_attributes)
8
8
  }.size
9
9
  end
10
10
 
11
11
  def read(query)
12
- Request.get(query.model.name, query.params)
12
+ Request.get(query.model.storage_name, query.params)
13
13
  end
14
14
 
15
15
  def update(attrs, resources)
16
16
  resources.each do |resource|
17
17
  attr_hash = attrs.inject({}) { |h, (k, v)| h.merge(k.name => v) }
18
- response = Request.put(resource.model.name, resource.key, attr_hash)
18
+ response = Request.put(resource.model.storage_name, resource.key, attr_hash)
19
19
  properties = resource.model.properties.inspect
20
20
  response.except(:id).each do |k, v|
21
21
  if prop = properties[k.to_sym]
@@ -27,7 +27,7 @@ module Restful
27
27
 
28
28
  def delete(resources)
29
29
  resources.each do |resource|
30
- Request.delete(resource.model.name, resource.key)
30
+ Request.delete(resource.model.storage_name, resource.key)
31
31
  end.size
32
32
  end
33
33
  end
@@ -2,24 +2,24 @@ module Restful
2
2
  module Request
3
3
  extend self
4
4
 
5
- def post(model_name, attrs)
6
- Configuration.backend.call(:post, resourceify(model_name), attrs)
5
+ def post(storage_name, attrs)
6
+ Configuration.backend.call(:post, resourceify(storage_name), attrs)
7
7
  end
8
8
 
9
- def get(model_name, attrs)
10
- Configuration.backend.call(:get, resourceify(model_name), attrs)
9
+ def get(storage_name, attrs)
10
+ Configuration.backend.call(:get, resourceify(storage_name), attrs)
11
11
  end
12
12
 
13
- def put(model_name, id, attrs)
14
- Configuration.backend.call(:put, resourceify(model_name, id), model_name.downcase => attrs)
13
+ def put(storage_name, id, attrs)
14
+ Configuration.backend.call(:put, resourceify(storage_name, id), storage_name.singularize => attrs)
15
15
  end
16
16
 
17
- def delete(model_name, id)
18
- Configuration.backend.call(:delete, resourceify(model_name, id))
17
+ def delete(storage_name, id)
18
+ Configuration.backend.call(:delete, resourceify(storage_name, id))
19
19
  end
20
20
 
21
- def resourceify(model_name, id=nil)
22
- [Configuration.domain, model_name.downcase.pluralize, id].compact.join('/')
21
+ def resourceify(storage_name, id=nil)
22
+ [Configuration.domain, storage_name, id].compact.join('/')
23
23
  end
24
24
  end
25
25
  end
@@ -1,7 +1,7 @@
1
1
  module DataMapper
2
2
  module Adapters
3
3
  module RestfulAdapter
4
- VERSION = '0.0.1'
4
+ VERSION = '0.0.2'
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dm-restful-adapter
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ryan Moran
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2012-04-11 00:00:00 -07:00
19
+ date: 2012-04-13 00:00:00 -07:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency