jwagener-oauth-active-resource 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 1
4
- :patch: 5
4
+ :patch: 6
@@ -72,23 +72,27 @@ module OAuthActiveResource
72
72
  # stranger = User.find(987)
73
73
  # user.friends << stranger
74
74
  # user.friends.save
75
- # => sends a PUT with collection of friends to http://example.com/users/123/friends
75
+ # => sends a PUT with collection of friends to http://example.com/users/123/friends ## OUTDATED!!?
76
76
 
77
77
  def self.has_many(*args)
78
78
  args.each do |k|
79
79
  name = k.to_s
80
80
  singular = name.singularize
81
- define_method(k) do
82
- if @has_many_cache.nil?
83
- @has_many_cache = {}
84
- end
85
- if not @has_many_cache[name]
81
+ define_method(k) do |*options|
82
+
83
+ options = options.first || {}
84
+ #if @has_many_cache.nil?
85
+ # @has_many_cache = {}
86
+ #end
87
+ @has_many_cache ||= {}
88
+ cache_name = "#{name}#{options.hash}"
89
+ if not @has_many_cache[cache_name]
86
90
 
87
91
  collection_path = "/#{self.element_name.pluralize}/#{self.id}/#{name}"
88
92
  resource = find_or_create_resource_for(singular)
89
- @has_many_cache[name] = OAuthActiveResource::UniqueResourceArray.new(self.connection,resource,collection_path)
93
+ @has_many_cache[cache_name] = OAuthActiveResource::UniqueResourceArray.new(self.connection,resource,collection_path,options)
90
94
  end
91
- return @has_many_cache[name]
95
+ return @has_many_cache[cache_name]
92
96
  end
93
97
  end
94
98
  end
@@ -38,12 +38,13 @@ module OAuthActiveResource
38
38
 
39
39
  # see has_many in Resource
40
40
  class UniqueResourceArray < UniqueArray
41
- def initialize(connection, resource, collection_path)
41
+ def initialize(connection, resource, collection_path,options = {})
42
42
  super()
43
43
 
44
44
  @connection = connection
45
45
  @collection_path = collection_path
46
46
  @resource = resource
47
+ @options = options
47
48
  reload
48
49
  end
49
50
 
@@ -78,7 +79,7 @@ module OAuthActiveResource
78
79
  end
79
80
 
80
81
  def reload
81
- self.replace(@resource.find(:all, :from => @collection_path))
82
+ self.replace(@resource.find(:all, :from => @collection_path, :params => @options))
82
83
  return self
83
84
  end
84
85
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jwagener-oauth-active-resource
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Johannes Wagener