remotable 0.2.5.beta2 → 0.3.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bafa573e3a1665e4e5e26c14d06326d953de1232
4
- data.tar.gz: 13cf353936b00ab92a8a1d1fd2dfc9d35098288f
3
+ metadata.gz: 85b05a6cc382c7d6d7c3308804b4feb1f78146b9
4
+ data.tar.gz: bf62759812b727023fbea3535e9b5a414d785e38
5
5
  SHA512:
6
- metadata.gz: 1df144f380b385f74558f8c5a8003a0b74962ac948fd72c23f4b97b5b0a459f3c1eddb6bf529c0c1b42f5dd915de7998fac23f46948b6efefc9b9d9b3cf09a3f
7
- data.tar.gz: 8f8585e47f6dade2c263787546ff5ab0f7a95a291df5066d246d827296ed9b83d9b5255039d2ef10ca33dfdaecf70eaff7ab935767ba3c2bbfd9849cc5c38ac9
6
+ metadata.gz: fb553ea2e7a419ef3d8fc80554fd60ebccc6e09601098a2dc535aa225393af060058ac18ac888472e3a2394b3e9a2815ae6ee0cdd99594eb6373828366deb1f4
7
+ data.tar.gz: 820228c09fc5bf588c039923782ef1b2799f5116eafc6ae8b6b0818eef72b433cf297048c5c5aba78ab6ce142fb8a105d35bee567d83e4b344ce7dc65789240f
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- remotable (0.2.5.beta2)
4
+ remotable (0.3.0.beta1)
5
5
  activerecord
6
6
  activeresource
7
7
  activesupport
@@ -28,7 +28,14 @@ module Remotable
28
28
  @remote_attribute_map ||= default_remote_attributes.map_to_self
29
29
  @local_attribute_routes ||= {}
30
30
  @expires_after ||= 1.day
31
- @remote_timeout = { :index => 4, :show => 1, :update => 2, :create => 2, :destroy => 2 }
31
+ @remote_timeout = {
32
+ :list => 4, # when we're getting many remote resources
33
+ :fetch => 4, # when we're getting a remote resource that doesn't exist locally
34
+ :pull => 1, # when we're getting a remote resource to refresh a local one
35
+ :update => 2, # when we're updaing a remote resource
36
+ :create => 2, # when we're creating a remote resource
37
+ :destroy => 2 # when we're destroying a remote resource
38
+ }
32
39
  end
33
40
 
34
41
 
@@ -92,7 +99,7 @@ module Remotable
92
99
  def remote_timeout(*args)
93
100
  if args.any?
94
101
  @remote_timeout = n = args.first
95
- @remote_timeout = {:index => n, :show => n, :create => n, :update => n, :destroy => n} if n.is_a?(Numeric)
102
+ @remote_timeout = {:list => n, :fetch => n, :pull => n, :create => n, :update => n, :destroy => n} if n.is_a?(Numeric)
96
103
  end
97
104
  @remote_timeout
98
105
  end
@@ -176,6 +183,8 @@ module Remotable
176
183
 
177
184
 
178
185
 
186
+ # !todo: create these methods on an anonymous module and mix it in
187
+
179
188
  def respond_to?(method_sym, include_private=false)
180
189
  return true if recognize_remote_finder_method(method_sym)
181
190
  super(method_sym, include_private)
@@ -256,7 +265,7 @@ module Remotable
256
265
  end
257
266
 
258
267
  def invoke_remote_model_find_by(remote_attr, *values)
259
- remote_set_timeout :show
268
+ remote_set_timeout :fetch
260
269
 
261
270
  find_by = remote_model.method(:find_by)
262
271
  case find_by.arity
@@ -268,7 +277,7 @@ module Remotable
268
277
  end
269
278
 
270
279
  def invoke_remote_model_find_by_for_local(local_resource, remote_attr, *values)
271
- remote_set_timeout :show
280
+ remote_set_timeout :pull
272
281
 
273
282
  find_by_for_local = remote_model.method(:find_by_for_local)
274
283
  case find_by_for_local.arity
@@ -314,7 +323,7 @@ module Remotable
314
323
  end
315
324
 
316
325
  def find_by_remote_query(remote_method_name, *args)
317
- remote_set_timeout :index
326
+ remote_set_timeout :list
318
327
  remote_resources = Array.wrap(remote_model.send(remote_method_name, *args))
319
328
  map_remote_resources_to_local(remote_resources)
320
329
  end
@@ -361,14 +370,13 @@ module Remotable
361
370
 
362
371
 
363
372
 
373
+ private
374
+
364
375
  def remote_set_timeout(mode)
365
376
  remote_model.timeout = remote_timeout[mode] if remote_model.respond_to?(:timeout=)
366
377
  end
367
378
 
368
379
 
369
-
370
- private
371
-
372
380
  def default_remote_attributes
373
381
  column_names - %w{id created_at updated_at expires_at}
374
382
  end
@@ -400,7 +408,6 @@ module Remotable
400
408
  :local_attribute_names,
401
409
  :local_attribute_name,
402
410
  :expires_after,
403
- :remote_set_timeout,
404
411
  :to => "self.class"
405
412
 
406
413
  def expired?
@@ -571,5 +578,11 @@ module Remotable
571
578
 
572
579
 
573
580
 
581
+ private
582
+
583
+ def remote_set_timeout(mode)
584
+ self.class.send :remote_set_timeout, mode
585
+ end
586
+
574
587
  end
575
588
  end
@@ -1,3 +1,3 @@
1
1
  module Remotable
2
- VERSION = "0.2.5.beta2"
2
+ VERSION = "0.3.0.beta1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: remotable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5.beta2
4
+ version: 0.3.0.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Lail
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-18 00:00:00.000000000 Z
11
+ date: 2014-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activeresource