ruby_json_api_client 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ruby_json_api_client/base.rb +12 -0
- data/lib/ruby_json_api_client/version.rb +1 -1
- data/spec/unit/base_spec.rb +24 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a76ad21204734d895e58f15133b82a449b8fadb
|
4
|
+
data.tar.gz: 8c00fc9611a86d4654ee295f9bfbb89f616a9beb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a112581a8770b6740771c6a3a3475395915c925b55bc3420028caed7ec8629bf894fb67641333a83c6f19fbdc38099727562e30a34b62ac2972e2c8b7e9e282d
|
7
|
+
data.tar.gz: 16c1be8a3bffb30f4e173a9c6c13fe6dea6eb3838ab4a7812c090857bc297cccbfdad2089c578c9a6bfaba16d5711b361a751341ded1d2ff1930f58372c66d06
|
@@ -135,6 +135,18 @@ module RubyJsonApiClient
|
|
135
135
|
!!send(self.class._identifier)
|
136
136
|
end
|
137
137
|
|
138
|
+
def new_record?
|
139
|
+
!persisted?
|
140
|
+
end
|
141
|
+
|
142
|
+
def marked_for_destruction?
|
143
|
+
@marked_for_destruction
|
144
|
+
end
|
145
|
+
|
146
|
+
def _destroy
|
147
|
+
marked_for_destruction?
|
148
|
+
end
|
149
|
+
|
138
150
|
def reload
|
139
151
|
RubyJsonApiClient::Store.instance.reload(self)
|
140
152
|
end
|
data/spec/unit/base_spec.rb
CHANGED
@@ -69,6 +69,30 @@ describe RubyJsonApiClient::Base do
|
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
|
+
describe :new_record? do
|
73
|
+
it "should not be a new record if it has an id" do
|
74
|
+
person = Person.new
|
75
|
+
person.instance_variable_set(:@id, 1)
|
76
|
+
expect(person.new_record?).to eql(false)
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should be a new record if there is no id" do
|
80
|
+
expect(Person.new.new_record?).to eql(true)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
describe :marked_for_destruction? do
|
85
|
+
it "should return false by default" do
|
86
|
+
expect(!!Person.new.marked_for_destruction?).to eql(false)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe :_destroy do
|
91
|
+
it "should return false by default" do
|
92
|
+
expect(!!Person.new._destroy).to eql(false)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
72
96
|
describe :== do
|
73
97
|
context "two objects of different classes" do
|
74
98
|
subject { Person.new(id: 1) == Item.new(id: 1) }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_json_api_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Toronto
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-02-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|