active_remote 1.8.0.rc1 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/active_remote/persistence.rb +16 -0
- data/lib/active_remote/version.rb +1 -1
- data/spec/lib/active_remote/persistence_spec.rb +15 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 154ae248e9618fac38d9763ac0b1db9a24ca1bed
|
4
|
+
data.tar.gz: d7183b2c5ea1a115cca2e8e121cd9c396aed8616
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f0b578fe625da16d035e0cddf0941138265c2242ed8c6fa30de4da4ca1bbda0c7eb52e9b0a85fe8e1e2b82a8d3425f40efd9494983df36cd944d9f4c77c0be7
|
7
|
+
data.tar.gz: b85fcc8bba929d5abe8a1adac36b8c30baea17dec7ffdb4038a3068a15eb92fc8c085cfaea298839fd1189297d76ef8fe8fefc9a3ca25d4f8e2f85a548d53186
|
@@ -51,6 +51,16 @@ module ActiveRemote
|
|
51
51
|
remote
|
52
52
|
end
|
53
53
|
|
54
|
+
# Instantiate a record with the given remote attributes. Generally used
|
55
|
+
# when retrieving records that already exist, so @new_record is set to false.
|
56
|
+
#
|
57
|
+
def instantiate(attributes, options = {})
|
58
|
+
new_object = self.new.instantiate(attributes)
|
59
|
+
new_object.readonly! if options[:readonly]
|
60
|
+
|
61
|
+
new_object
|
62
|
+
end
|
63
|
+
|
54
64
|
# Mark the class as readonly. Overrides instance-level readonly, making
|
55
65
|
# any instance of this class readonly.
|
56
66
|
def readonly!
|
@@ -146,6 +156,12 @@ module ActiveRemote
|
|
146
156
|
return ! new_record?
|
147
157
|
end
|
148
158
|
|
159
|
+
# Sets the instance to be a readonly object
|
160
|
+
#
|
161
|
+
def readonly!
|
162
|
+
@readonly = true
|
163
|
+
end
|
164
|
+
|
149
165
|
# Returns true if the remote class or remote record is readonly; otherwise, returns false.
|
150
166
|
def readonly?
|
151
167
|
self.class.readonly? || @readonly
|
@@ -130,6 +130,15 @@ describe ActiveRemote::Persistence do
|
|
130
130
|
end
|
131
131
|
end
|
132
132
|
|
133
|
+
describe "#readonly?" do
|
134
|
+
context "when the record is created through instantiate with options[:readonly]" do
|
135
|
+
subject { Tag.instantiate({:guid => 'foo'}, :readonly => true) }
|
136
|
+
|
137
|
+
its(:new_record?) { should be_false }
|
138
|
+
its(:readonly?) { should be_true }
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
133
142
|
describe "#has_errors?" do
|
134
143
|
context "when errors are not present" do
|
135
144
|
before { subject.errors.clear }
|
@@ -145,6 +154,12 @@ describe ActiveRemote::Persistence do
|
|
145
154
|
end
|
146
155
|
|
147
156
|
describe "#new_record?" do
|
157
|
+
context "when the record is created through instantiate" do
|
158
|
+
subject { Tag.instantiate(:guid => 'foo') }
|
159
|
+
|
160
|
+
its(:new_record?) { should be_false }
|
161
|
+
end
|
162
|
+
|
148
163
|
context "when the record is persisted" do
|
149
164
|
subject { Tag.allocate.instantiate(:guid => 'foo') }
|
150
165
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_remote
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.8.0
|
4
|
+
version: 1.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Hutchison
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_attr
|
@@ -235,9 +235,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
235
235
|
version: '0'
|
236
236
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
237
237
|
requirements:
|
238
|
-
- - '
|
238
|
+
- - '>='
|
239
239
|
- !ruby/object:Gem::Version
|
240
|
-
version:
|
240
|
+
version: '0'
|
241
241
|
requirements: []
|
242
242
|
rubyforge_project:
|
243
243
|
rubygems_version: 2.2.1
|