hyperresource 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2fd8d70a1aa3c15bde69a7a26ca532232c1795cd
4
- data.tar.gz: 87cf162990ed41accbb7fdf7b3bcc2abded565f7
3
+ metadata.gz: e9844c60b0fe8e4e88935179b8adac2484267087
4
+ data.tar.gz: ba30d1358140c121509ff9ccbdca0c7b1f09fe72
5
5
  SHA512:
6
- metadata.gz: 3b6b9a4e0a3e19f78af2d68ac3b9fe208b1db41b0dc413f393d9a7b20a66ea853f95e2836f9524406573251d42cb5cbaab642b6489c7d7f5a1ee216ffadf426a
7
- data.tar.gz: 62fc3bf454b4b54427c9d481c4556039119ba48ddcddbda4aee3c14f68f1b2d3288a7ccebbf2ef38b1b3fbe2914ef4b83f06c93a6bc70c082a4875f1985d396d
6
+ metadata.gz: 5b81b62a0f28580101f4e3bce8b5db8bde5081d31874ca549ea06e2158a29ab60bfccc20aabd44c39da1672d83aed82793dfd171b83e206865fdf08c69df88f0
7
+ data.tar.gz: bc318b9f9231913ac6cf40401a590755fc76f91baa9cafbfa46960d2f8baf4e66905664a52e2f2aaacbfb584716d426cede5035a32241b6e0f5e02c9efa033d8
@@ -118,8 +118,7 @@ public
118
118
 
119
119
  ## Returns the *i*th object in the first collection of objects embedded
120
120
  ## in this resource. Equivalent to +self.objects[i]+.
121
- def [](i); self.objects[i] end
122
-
121
+ def [](i); self.objects.ith(i) end
123
122
 
124
123
  ## method_missing will load this resource if not yet loaded, then
125
124
  ## attempt to delegate to +attributes+, then +objects+,
@@ -1,9 +1,11 @@
1
1
  class HyperResource::Attributes < Hash
2
2
  attr_accessor :parent_resource
3
+
3
4
  def initialize(resource=nil)
4
5
  self.parent_resource = resource || HyperResource.new
5
6
  end
6
- # Initialize attributes from a HAL response.
7
+
8
+ ## Initialize attributes from a HAL response.
7
9
  def init_from_hal(hal_resp)
8
10
  (hal_resp.keys - ['_links', '_embedded']).map(&:to_s).each do |attr|
9
11
  self[attr] = hal_resp[attr]
@@ -14,9 +16,10 @@ class HyperResource::Attributes < Hash
14
16
  end
15
17
 
16
18
  unless self.parent_resource.respond_to?(attr.to_sym)
17
- self.parent_resource.define_singleton_method(attr.to_sym) {self[attr]}
19
+ self.parent_resource.define_singleton_method(attr.to_sym) {
20
+ self.attributes[attr]}
18
21
  self.parent_resource.define_singleton_method("#{attr}=".to_sym) do |v|
19
- self[attr] = v
22
+ self.attributes[attr] = v
20
23
  end
21
24
  end
22
25
  end
@@ -13,7 +13,9 @@ class HyperResource::Objects < Hash
13
13
  define_singleton_method(name.to_sym) { self[name] }
14
14
  end
15
15
  unless self.parent_resource.respond_to?(name.to_sym)
16
- self.parent_resource.define_singleton_method(name.to_sym) {self[name]}
16
+ self.parent_resource.define_singleton_method(name.to_sym) do
17
+ self.objects[name]
18
+ end
17
19
  end
18
20
  end
19
21
  end
@@ -21,11 +23,11 @@ class HyperResource::Objects < Hash
21
23
  ## Returns the first item in the first collection in +self+.
22
24
  alias_method :first_orig, :first
23
25
  def first
24
- self.first_orig[1][0]
26
+ self.first_orig[1][0] rescue caller
25
27
  end
26
28
 
27
29
  ## Returns the ith item in the first collection in +self+.
28
- def [](i)
29
- self.first_orig[1][i]
30
+ def ith(i)
31
+ self.first_orig[1][i] rescue caller
30
32
  end
31
33
  end
@@ -1,4 +1,4 @@
1
1
  class HyperResource
2
- VERSION = '0.1.0'
3
- VERSION_DATE = '2013-04-07'
2
+ VERSION = '0.1.1'
3
+ VERSION_DATE = '2013-04-08'
4
4
  end
@@ -0,0 +1,2 @@
1
+ require 'hyper_resource'
2
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hyperresource
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pete Gamache
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-04-07 00:00:00.000000000 Z
11
+ date: 2013-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: uri_template
@@ -100,6 +100,7 @@ files:
100
100
  - lib/hyper_resource/response.rb
101
101
  - lib/hyper_resource/version.rb
102
102
  - lib/hyper_resource.rb
103
+ - lib/hyperresource.rb
103
104
  homepage: https://github.com/gamache/hyperresource
104
105
  licenses:
105
106
  - MIT
@@ -120,9 +121,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
121
  version: '0'
121
122
  requirements: []
122
123
  rubyforge_project:
123
- rubygems_version: 2.0.2
124
+ rubygems_version: 2.0.3
124
125
  signing_key:
125
126
  specification_version: 4
126
127
  summary: Extensible hypermedia client for Ruby
127
128
  test_files: []
128
- has_rdoc: true