harpy 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,6 +5,5 @@ rvm:
5
5
  - ree
6
6
  - 1.9.2
7
7
  - ruby-head
8
- - jruby
9
8
  notifications:
10
9
  disabled: true
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- harpy (0.2.0)
4
+ harpy (0.2.1)
5
5
  activemodel (>= 3.1.0)
6
6
  activesupport (>= 3.1.0)
7
7
  hash-deep-merge (~> 0.1.1)
@@ -124,11 +124,18 @@ module Harpy
124
124
 
125
125
  module InstanceMethods
126
126
  def initialize(attrs = nil)
127
- @attrs = attrs || {}
127
+ @attrs = {}
128
+ self.attributes = attrs || {}
128
129
  end
129
130
 
130
131
  def attributes=(attrs)
131
- @attrs.merge! attrs
132
+ attrs.each do |key, value|
133
+ if respond_to? "#{key}="
134
+ send "#{key}=", value
135
+ else
136
+ @attrs[key] = value
137
+ end
138
+ end
132
139
  end
133
140
 
134
141
  def as_json(*args)
@@ -1,3 +1,3 @@
1
1
  module Harpy
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
@@ -19,6 +19,7 @@ module Harpy
19
19
  module Spec
20
20
  class Company
21
21
  include Harpy::Resource
22
+ attr_accessor :tax_id
22
23
  end
23
24
  class User
24
25
  include Harpy::Resource
@@ -409,6 +410,14 @@ describe "class including Harpy::Resource" do
409
410
  subject.should_receive(:persisted?).and_return true
410
411
  lambda{ subject.name }.should raise_error NoMethodError
411
412
  end
413
+ it "use existing setters if available" do
414
+ company = Harpy::Spec::Company.new "tax_id" => "123"
415
+ company.tax_id.should == "123"
416
+ company.as_json.should == {}
417
+ company.attributes = {:tax_id => 123}
418
+ company.tax_id.should == 123
419
+ company.as_json.should == {}
420
+ end
412
421
  end
413
422
  describe "advanced attribute readers" do
414
423
  let(:url){ "http://localhost/company/1" }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: harpy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,12 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2011-09-13 00:00:00.000000000 +02:00
14
- default_executable:
13
+ date: 2011-09-29 00:00:00.000000000Z
15
14
  dependencies:
16
15
  - !ruby/object:Gem::Dependency
17
16
  name: typhoeus
18
- requirement: &2154158000 !ruby/object:Gem::Requirement
17
+ requirement: &2153230160 !ruby/object:Gem::Requirement
19
18
  none: false
20
19
  requirements:
21
20
  - - ~>
@@ -23,10 +22,10 @@ dependencies:
23
22
  version: 0.2.4
24
23
  type: :runtime
25
24
  prerelease: false
26
- version_requirements: *2154158000
25
+ version_requirements: *2153230160
27
26
  - !ruby/object:Gem::Dependency
28
27
  name: activesupport
29
- requirement: &2154157480 !ruby/object:Gem::Requirement
28
+ requirement: &2153229440 !ruby/object:Gem::Requirement
30
29
  none: false
31
30
  requirements:
32
31
  - - ! '>='
@@ -34,10 +33,10 @@ dependencies:
34
33
  version: 3.1.0
35
34
  type: :runtime
36
35
  prerelease: false
37
- version_requirements: *2154157480
36
+ version_requirements: *2153229440
38
37
  - !ruby/object:Gem::Dependency
39
38
  name: activemodel
40
- requirement: &2154157000 !ruby/object:Gem::Requirement
39
+ requirement: &2153228860 !ruby/object:Gem::Requirement
41
40
  none: false
42
41
  requirements:
43
42
  - - ! '>='
@@ -45,10 +44,10 @@ dependencies:
45
44
  version: 3.1.0
46
45
  type: :runtime
47
46
  prerelease: false
48
- version_requirements: *2154157000
47
+ version_requirements: *2153228860
49
48
  - !ruby/object:Gem::Dependency
50
49
  name: hash-deep-merge
51
- requirement: &2154156520 !ruby/object:Gem::Requirement
50
+ requirement: &2153228200 !ruby/object:Gem::Requirement
52
51
  none: false
53
52
  requirements:
54
53
  - - ~>
@@ -56,10 +55,10 @@ dependencies:
56
55
  version: 0.1.1
57
56
  type: :runtime
58
57
  prerelease: false
59
- version_requirements: *2154156520
58
+ version_requirements: *2153228200
60
59
  - !ruby/object:Gem::Dependency
61
60
  name: yajl-ruby
62
- requirement: &2154156040 !ruby/object:Gem::Requirement
61
+ requirement: &2153227620 !ruby/object:Gem::Requirement
63
62
  none: false
64
63
  requirements:
65
64
  - - ~>
@@ -67,10 +66,10 @@ dependencies:
67
66
  version: 0.8.2
68
67
  type: :runtime
69
68
  prerelease: false
70
- version_requirements: *2154156040
69
+ version_requirements: *2153227620
71
70
  - !ruby/object:Gem::Dependency
72
71
  name: rake
73
- requirement: &2154155560 !ruby/object:Gem::Requirement
72
+ requirement: &2153227000 !ruby/object:Gem::Requirement
74
73
  none: false
75
74
  requirements:
76
75
  - - ~>
@@ -78,10 +77,10 @@ dependencies:
78
77
  version: 0.8.7
79
78
  type: :development
80
79
  prerelease: false
81
- version_requirements: *2154155560
80
+ version_requirements: *2153227000
82
81
  - !ruby/object:Gem::Dependency
83
82
  name: rspec
84
- requirement: &2156182600 !ruby/object:Gem::Requirement
83
+ requirement: &2153226440 !ruby/object:Gem::Requirement
85
84
  none: false
86
85
  requirements:
87
86
  - - ~>
@@ -89,10 +88,10 @@ dependencies:
89
88
  version: 2.6.0
90
89
  type: :development
91
90
  prerelease: false
92
- version_requirements: *2156182600
91
+ version_requirements: *2153226440
93
92
  - !ruby/object:Gem::Dependency
94
93
  name: rocco
95
- requirement: &2156182120 !ruby/object:Gem::Requirement
94
+ requirement: &2153225920 !ruby/object:Gem::Requirement
96
95
  none: false
97
96
  requirements:
98
97
  - - ~>
@@ -100,7 +99,7 @@ dependencies:
100
99
  version: '0.7'
101
100
  type: :development
102
101
  prerelease: false
103
- version_requirements: *2156182120
102
+ version_requirements: *2153225920
104
103
  description: Client for REST API with HATEOAS
105
104
  email:
106
105
  - joseph.halter@thetalentbox.com
@@ -129,7 +128,6 @@ files:
129
128
  - spec/harpy/resource_spec.rb
130
129
  - spec/harpy_spec.rb
131
130
  - spec/spec_helper.rb
132
- has_rdoc: true
133
131
  homepage: https://github.com/TalentBox/harpy
134
132
  licenses: []
135
133
  post_install_message:
@@ -150,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
150
148
  version: '0'
151
149
  requirements: []
152
150
  rubyforge_project:
153
- rubygems_version: 1.6.2
151
+ rubygems_version: 1.8.6
154
152
  signing_key:
155
153
  specification_version: 3
156
154
  summary: Client for REST API