restly 0.0.1.alpha.2 → 0.0.1.alpha.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -26,12 +26,16 @@ class Restly::Associations::Base
26
26
 
27
27
  def load_collection(parent, association_class = self.association_class)
28
28
  raise Restly::Error::AssociationError, "Not a collection" unless collection?
29
+ return [] if embedded?
29
30
  Restly::Proxies::Associations::Collection.new(association_class.all, parent)
30
31
  end
31
32
 
32
33
  def load_instance(parent, association_class = self.association_class)
33
34
  raise Restly::Error::AssociationError, "Not an instance" if collection?
34
- instance = if (foreign_key = parent.attributes["#{name}_id"])
35
+ return nil if embedded?
36
+ instance = if parent.attributes.has_key? "#{name}_id"
37
+ foreign_key = parent.attributes["#{name}_id"]
38
+ return nil unless foreign_key
35
39
  association_class.find(foreign_key)
36
40
  else
37
41
  association_class.instance_from_response association_class.connection.get(association_class.path)
@@ -1,10 +1,10 @@
1
1
  module Restly::Base::Resource::Finders
2
2
 
3
- def find(*args)
3
+ def find(id, *args)
4
4
  options = args.extract_options!
5
5
 
6
6
  #params[pagination_options[:params][:page]] = options[:page] if pagination
7
- instance_from_response connection.get(path_with_format(args.first), params: params)
7
+ instance_from_response connection.get(path_with_format(id), params: params)
8
8
  end
9
9
 
10
10
  def all
@@ -16,8 +16,6 @@ module Restly::Base::Resource::Finders
16
16
  instance.save
17
17
  end
18
18
 
19
- private
20
-
21
19
  def collection_from_response(response)
22
20
  raise Restly::Error::InvalidResponse unless response.is_a? OAuth2::Response
23
21
  Restly::Collection.new self, nil, response: response
@@ -1,3 +1,3 @@
1
1
  module Restly
2
- VERSION = "0.0.1.alpha.2"
2
+ VERSION = "0.0.1.alpha.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: restly
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.alpha.2
4
+ version: 0.0.1.alpha.3
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-30 00:00:00.000000000 Z
12
+ date: 2012-10-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: oauth2