remote_record 0.4.0 → 0.5.0

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
  SHA256:
3
- metadata.gz: 285bbd2e1d94c57c73399a83c336404b2eb190e4b08e14287671152cf36dc866
4
- data.tar.gz: 9b3ce895695588e43516e86a9498ed64d33ad76771afa13e739835dc12175abb
3
+ metadata.gz: 4bf471bd03525a3f6dfdfedc1d88e2681264c85e98447607259fec7a94d56ddd
4
+ data.tar.gz: 076113352a325ee80c09cca58a00cdd8e703a584392319f008393fdae90ddbc2
5
5
  SHA512:
6
- metadata.gz: d9105b2bd550f9553e2c04c8caa2a1ca1933628e51c3ccf318bc19c62721be4302d1ca490f29ab194dee971642ebb045f102b8e5a8179e3362cb630c7ae8db0a
7
- data.tar.gz: 24966ceeb7d708fedaf6413e98496c485f77314d1837ca15cc5d7db9cd1d2e6ed0f3c06d50f7f709cc77f430e36b3f66d18e09e3970b246813b3e2e1c057d528
6
+ metadata.gz: 3dc11719e885adf6220ef9b351b1605943ce25220c3e95ee0ee8820175685783777ed7f1bd43f22249f83cb95e8031509e2b85f8be04b65dc33aaab0c4fdca22
7
+ data.tar.gz: 478180ddc5b281c7a9873313608ad62368f9c947125fd1095b1c61a88e9cce5147637ca1391c801a0af1c2f53e4ac34418256a38563893f926a4f55ee37d62b4
data/README.md CHANGED
@@ -1,6 +1,20 @@
1
- # RemoteRecord
1
+ ![RemoteRecord: Ready-made remote resource structures.](doc/header.svg)
2
2
 
3
- Ready-made remote resource structures.
3
+ ---
4
+
5
+ ![Remote Record](https://github.com/raisedevs/remote_record/workflows/Remote%20Record/badge.svg)
6
+ [![Gem Version](https://badge.fury.io/rb/remote_record.svg)](https://badge.fury.io/rb/remote_record)
7
+
8
+ Every API speaks a different language. Maybe it's REST, maybe it's SOAP, maybe
9
+ it's GraphQL. Maybe it's got its own Ruby client, or maybe you need to roll your
10
+ own. But what if you could just pretend it existed in your database?
11
+
12
+ RemoteRecord provides a consistent ActiveRecord inspired interface for all of
13
+ your application's APIs. Store remote resources by ID, and RemoteRecord will
14
+ auto-populate instances of your ActiveRecord model with their attributes from
15
+ the API. Whether you're dealing with a user on GitHub, a track on Spotify, a
16
+ place on Google Maps, or a resource on your internal infrastructure, you can use
17
+ RemoteRecord to wrap fetching it.
4
18
 
5
19
  ## Setup
6
20
 
@@ -114,3 +128,7 @@ gain support for caching.
114
128
 
115
129
  You might want to force a fresh request in some instances, even if you're using
116
130
  `memoize`. To do this, call `fresh` on a reference, and it'll be repopulated.
131
+
132
+ ### Skip fetching
133
+
134
+ You might not want to make a request on initialize sometimes. In this case, pass `fetching: false` to your query or `new` to make sure the resource isn't fetched.
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'active_support/concern'
4
+ require 'active_support/rescuable'
4
5
  require 'remote_record/base'
5
6
  require 'remote_record/class_lookup'
6
7
  require 'remote_record/config'
@@ -3,6 +3,8 @@
3
3
  module RemoteRecord
4
4
  # Remote record classes should inherit from this class and define #get.
5
5
  class Base
6
+ include ActiveSupport::Rescuable
7
+
6
8
  def self.default_config
7
9
  Config.defaults.merge(remote_record_class: self)
8
10
  end
@@ -27,6 +27,7 @@ module RemoteRecord
27
27
 
28
28
  # rubocop:disable Metrics/BlockLength
29
29
  included do
30
+ include ActiveSupport::Rescuable
30
31
  attr_accessor :fetching
31
32
 
32
33
  after_initialize do |reference|
@@ -52,6 +53,8 @@ module RemoteRecord
52
53
 
53
54
  def fetch_remote_resource
54
55
  instance.fetch if fetching
56
+ rescue Exception => e # rubocop:disable Lint/RescueException
57
+ rescue_with_handler(e) || raise
55
58
  end
56
59
 
57
60
  def fresh
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RemoteRecord
4
- VERSION = '0.4.0'
4
+ VERSION = '0.5.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: remote_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simon Fish