effective_resources 0.8.11 → 0.8.12

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: 085758676d246a9dd5d66beaafb5cdaf9590e25d
4
- data.tar.gz: d9e777683dbe93f7e8aa8729f88f9731ad5b09ae
3
+ metadata.gz: 6d9f3c476a1b25d899e3ef80460fd11bf5738949
4
+ data.tar.gz: bff4db8bfebd28a8b194e390837a2509aff6f9fd
5
5
  SHA512:
6
- metadata.gz: 730e4cecbdbfd7ee0fac449657e90d37bf40417c45ec4ab24519f50fb48588b2bf8c3e73eea0a355a70d0d793c3e301ee28e2b7ca53a2a6ff15d2438a809e7a5
7
- data.tar.gz: b95e549ee16faaceb680920bd3261109ac2a9cbf2b80c1b3eeda41e069657e6056aa2efd1150b7a0471dba359ebbb748126cfcb1bce5fa6a92325aba2190d9cd
6
+ metadata.gz: 036821b4210acece00173e2c1afd0aa406a11359b50b91f1d6eae3b1be4da035cdfacd104b5e8a8a2608a6aed8df1a3257b0991a16f01fd086fcf6df3f6921a6
7
+ data.tar.gz: 5b208d0903fc51e37e3236c40a22a06d4938e4679d3131dede7b7df358754072e54fc3b9abb429677ee2ff56c8de36688b94e99477dd8d23167310414cbca8b1
@@ -30,6 +30,7 @@ module ActsAsTokened
30
30
  def find(*args)
31
31
  return super unless args.length == 1
32
32
  return super if block_given?
33
+ return find_by_id(args.first) if @_effective_reloading
33
34
 
34
35
  find_by_token(args.first) || raise(::ActiveRecord::RecordNotFound.new("Couldn't find #{name} with 'token'=#{args.first}"))
35
36
  end
@@ -40,5 +41,16 @@ module ActsAsTokened
40
41
  token
41
42
  end
42
43
 
44
+ def to_global_id(**params)
45
+ GlobalID.new(URI::GID.build(app: Rails.application.config.global_id.app, model_name: model_name, model_id: to_param, params: params))
46
+ end
47
+
48
+ def reload(options = nil)
49
+ self.class.instance_variable_set(:@_effective_reloading, true)
50
+ retval = super
51
+ self.class.instance_variable_set(:@_effective_reloading, nil)
52
+ retval
53
+ end
54
+
43
55
  end
44
56
 
@@ -49,7 +49,10 @@ module Effective
49
49
  end
50
50
  end
51
51
 
52
- path = routes[action].format(resource || instance).presence
52
+ # This generates the correct route when an object is overriding to_param
53
+ formattable = (resource || instance).attributes.symbolize_keys.merge(id: (resource || instance).to_param)
54
+
55
+ path = routes[action].format(formattable).presence
53
56
 
54
57
  if path.present? && opts.present?
55
58
  uri = URI.parse(path)
@@ -118,7 +121,6 @@ module Effective
118
121
  def is_post_route?(route)
119
122
  ['POST', 'PUT', 'PATCH'].any? { |verb| route.verb == verb }
120
123
  end
121
-
122
124
  end
123
125
  end
124
126
  end
@@ -1,3 +1,3 @@
1
1
  module EffectiveResources
2
- VERSION = '0.8.11'.freeze
2
+ VERSION = '0.8.12'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_resources
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.11
4
+ version: 0.8.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect