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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f15daf36d3c8b8835e43b8fdbb36558e9272bf62
4
- data.tar.gz: ac509c0f6b2a10444c9b7fe1c8fc6a29dec7350e
3
+ metadata.gz: 154ae248e9618fac38d9763ac0b1db9a24ca1bed
4
+ data.tar.gz: d7183b2c5ea1a115cca2e8e121cd9c396aed8616
5
5
  SHA512:
6
- metadata.gz: 30d4f0bef9362330f7a52adf478766d4a4c9a24c4a9b1e92c359d12f4824444b4d4a55b9a78e85fbfc70f448086dd366467dba82952d99728e552c1635e7d13b
7
- data.tar.gz: 3f65730eb838053732644492642d4bd32d69d82cfe1be1452b75be61c08ca8f95212832364844d1b31c9b3acc885f7d09c2fcbfb0aeb5f4be873ef9bd01b767f
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
@@ -1,3 +1,3 @@
1
1
  module ActiveRemote
2
- VERSION = "1.8.0.rc1"
2
+ VERSION = "1.8.0"
3
3
  end
@@ -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.rc1
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-24 00:00:00.000000000 Z
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: 1.3.1
240
+ version: '0'
241
241
  requirements: []
242
242
  rubyforge_project:
243
243
  rubygems_version: 2.2.1