vidibus-resource 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -15,6 +15,12 @@ Add `gem "vidibus-resource"` to your Gemfile. Then call `bundle install` on your
15
15
  DESCRIBE
16
16
 
17
17
 
18
+ ## TODO
19
+
20
+ * Refactor
21
+ * Write specs
22
+
23
+
18
24
  ## Copyright
19
25
 
20
26
  © 2011 Andre Pankratz. See LICENSE for details.
@@ -6,7 +6,7 @@ class Api::ResourcesController < ApiController
6
6
  # Creates resource consumer on provider.
7
7
  def create
8
8
  @instance.add_resource_consumer(params["service"])
9
- render(:json => {:resource => @instance.fixed_resourceable_hash})
9
+ render(:json => {:resource => JSON.generate(@instance.resourceable_hash)})
10
10
  end
11
11
 
12
12
  # Updates resource on consumer.
@@ -23,9 +23,8 @@ module Vidibus::Resource
23
23
 
24
24
  # Registers this consumer with provider.
25
25
  def add_resource_consumer
26
- response = resource_provider.post("/api/resources/#{self.class.to_s.tableize}/#{uuid}")
27
- data = response["resource"]
28
- self.resource_attributes = fix_resource_attributes(data)
26
+ response = register_resource_consumer
27
+ self.resource_attributes = JSON.parse(response["resource"])
29
28
  set_resource_attributes(true)
30
29
  true # ensure true!
31
30
  end
@@ -98,6 +97,10 @@ module Vidibus::Resource
98
97
 
99
98
  private
100
99
 
100
+ def register_resource_consumer
101
+ resource_provider.post("/api/resources/#{self.class.to_s.tableize}/#{uuid}")
102
+ end
103
+
101
104
  module ClassMethods
102
105
 
103
106
  # Sets up resource provider service type and realm.
@@ -16,8 +16,10 @@ module Vidibus::Resource
16
16
  # Adds given resource consumer.
17
17
  def add_resource_consumer(service_uuid)
18
18
  list = resource_consumers || []
19
- list << service_uuid
20
- update_attributes(:resource_consumers => list.uniq)
19
+ unless list.include?(service_uuid)
20
+ list << service_uuid
21
+ update_attributes(:resource_consumers => list.uniq)
22
+ end
21
23
  end
22
24
 
23
25
  # Removes given resource consumer.
@@ -1,5 +1,5 @@
1
1
  module Vidibus
2
2
  module Resource
3
- VERSION = "0.2.0"
3
+ VERSION = "0.2.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vidibus-resource
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 0
10
- version: 0.2.0
9
+ - 1
10
+ version: 0.2.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Andre Pankratz