rest_model 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -26,32 +26,9 @@ class RestModel
26
26
 
27
27
  def from_hash(attrs, resource = nil)
28
28
  return nil if attrs.nil? or attrs.empty?
29
- resource ? update_from_hash(resource, attrs) : create_from_hash(attrs)
30
- end
31
29
 
32
- def create_from_hash(attrs)
33
30
  one? ? resource_class.new(attrs)
34
31
  : Array(attrs).map {|item| resource_class.new(item)}
35
32
  end
36
-
37
- def update_from_hash(resource, attrs)
38
- if one?
39
- resource.update_attributes(attrs)
40
- else
41
- if resource.count > attrs.count
42
- resource = resource.to(attrs.count - 1)
43
- end
44
-
45
- attrs.each_with_index do |item, index|
46
- if index < resource.count
47
- resource[index].update_attributes(item)
48
- else
49
- resource << create_from_hash(item)
50
- end
51
- end
52
-
53
- resource
54
- end
55
- end
56
33
  end
57
34
  end
@@ -1,3 +1,3 @@
1
1
  class RestModel
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
@@ -5,7 +5,7 @@ require "spec_helper"
5
5
  describe "update_attributes" do
6
6
  describe_example "update_attributes/embeds_one" do
7
7
  it "updates customer item name" do
8
- @root.item.id.should == "2000"
8
+ @root.item.id.should == nil
9
9
  @root.item.name.should == "name"
10
10
  end
11
11
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rest_model
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -15,7 +15,7 @@ date: 2011-10-20 00:00:00.000000000Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: activesupport
18
- requirement: &70274087258500 !ruby/object:Gem::Requirement
18
+ requirement: &70223287802460 !ruby/object:Gem::Requirement
19
19
  none: false
20
20
  requirements:
21
21
  - - ~>
@@ -23,10 +23,10 @@ dependencies:
23
23
  version: '3.0'
24
24
  type: :runtime
25
25
  prerelease: false
26
- version_requirements: *70274087258500
26
+ version_requirements: *70223287802460
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: i18n
29
- requirement: &70274087258000 !ruby/object:Gem::Requirement
29
+ requirement: &70223287801960 !ruby/object:Gem::Requirement
30
30
  none: false
31
31
  requirements:
32
32
  - - ! '>='
@@ -34,10 +34,10 @@ dependencies:
34
34
  version: '0.5'
35
35
  type: :runtime
36
36
  prerelease: false
37
- version_requirements: *70274087258000
37
+ version_requirements: *70223287801960
38
38
  - !ruby/object:Gem::Dependency
39
39
  name: rspec
40
- requirement: &70274087257540 !ruby/object:Gem::Requirement
40
+ requirement: &70223287801500 !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
43
  - - ~>
@@ -45,10 +45,10 @@ dependencies:
45
45
  version: '2.6'
46
46
  type: :development
47
47
  prerelease: false
48
- version_requirements: *70274087257540
48
+ version_requirements: *70223287801500
49
49
  - !ruby/object:Gem::Dependency
50
50
  name: guard
51
- requirement: &70274087257080 !ruby/object:Gem::Requirement
51
+ requirement: &70223287801040 !ruby/object:Gem::Requirement
52
52
  none: false
53
53
  requirements:
54
54
  - - ~>
@@ -56,10 +56,10 @@ dependencies:
56
56
  version: '0.5'
57
57
  type: :development
58
58
  prerelease: false
59
- version_requirements: *70274087257080
59
+ version_requirements: *70223287801040
60
60
  - !ruby/object:Gem::Dependency
61
61
  name: guard-rspec
62
- requirement: &70274087256620 !ruby/object:Gem::Requirement
62
+ requirement: &70223287800580 !ruby/object:Gem::Requirement
63
63
  none: false
64
64
  requirements:
65
65
  - - ~>
@@ -67,10 +67,10 @@ dependencies:
67
67
  version: '0.4'
68
68
  type: :development
69
69
  prerelease: false
70
- version_requirements: *70274087256620
70
+ version_requirements: *70223287800580
71
71
  - !ruby/object:Gem::Dependency
72
72
  name: growl
73
- requirement: &70274087256160 !ruby/object:Gem::Requirement
73
+ requirement: &70223287800120 !ruby/object:Gem::Requirement
74
74
  none: false
75
75
  requirements:
76
76
  - - ~>
@@ -78,7 +78,7 @@ dependencies:
78
78
  version: '1.0'
79
79
  type: :development
80
80
  prerelease: false
81
- version_requirements: *70274087256160
81
+ version_requirements: *70223287800120
82
82
  description: ''
83
83
  email:
84
84
  - victorcrodrigues@gmail.com