rails_settlement 1.4.2 → 1.5.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/rails_settlement/version.rb +1 -1
- data/lib/rails_settlement.rb +7 -3
- data/rails_settlement.gemspec +2 -2
- metadata +6 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 964bf8e0f084d6dfe8f471895e49f0d812fa6c0138ed771f5c4d9ee0bc617f73
|
|
4
|
+
data.tar.gz: ed7be25b7bc3ae6544cbe6aab452135a6e71d68d82553e18910554060ec45ac5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fe3fcefecdeb8b2ae1af0b3136bf4a1d10622c702e3e8cd4f2a9dc4a54b7782b8b080318ea979a1bcccba6ff9275b651ce1702f8f5a6e1ad9af1f2a8e74d4068
|
|
7
|
+
data.tar.gz: 1bfbce931bbc5536c2b70ed17cb9f2679ffaf34c6133682082fdb4e138062185c3939ce1efa67507f4c33b0b3ca0eb2695202cb08781dbe80d570979b380dfc7
|
data/lib/rails_settlement.rb
CHANGED
|
@@ -15,7 +15,7 @@ module RailsSettlement
|
|
|
15
15
|
super unless (matches = method.to_s.match(SETTABLE_REGEX))
|
|
16
16
|
|
|
17
17
|
variable, raisable = _rs_handle_match_data(matches)
|
|
18
|
-
klass = _rs_klass(variable, **options.
|
|
18
|
+
klass = _rs_klass(variable, **options.slice(:namespace))
|
|
19
19
|
param_options = _rs_param_options(klass: klass, options: options)
|
|
20
20
|
scoped_klass = _rs_handle_scopes(klass: klass, scopes: param_options[:scope_to])
|
|
21
21
|
associated_to = _rs_handle_associated_to(options: options)
|
|
@@ -24,7 +24,7 @@ module RailsSettlement
|
|
|
24
24
|
query = _rs_associated_scope(scoped_relation: scoped_klass, associated_to: associated_to)
|
|
25
25
|
|
|
26
26
|
instance_variable_set("@#{variable}", query.find_by(param_options[:model_key] => params[param_options[:params_key]]))
|
|
27
|
-
|
|
27
|
+
_rs_raise_record_not_found!(klass: klass, key: param_options[:model_key], id: params[param_options[:params_key]]) if raisable && instance_variable_get("@#{variable}").nil?
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
attr_reader variable
|
|
@@ -47,7 +47,7 @@ module RailsSettlement
|
|
|
47
47
|
end
|
|
48
48
|
|
|
49
49
|
def _rs_param_options(klass:, options:)
|
|
50
|
-
(klass.try(:settable_params) || {}).merge(options.
|
|
50
|
+
(klass.try(:settable_params) || {}).merge(options.slice(:model_key, :params_key, :scope_to))
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
def _rs_handle_scopes(klass:, scopes:)
|
|
@@ -71,6 +71,10 @@ module RailsSettlement
|
|
|
71
71
|
|
|
72
72
|
scoped_relation.joins(associated_to).where(associated_to => public_send(associated_to))
|
|
73
73
|
end
|
|
74
|
+
|
|
75
|
+
def _rs_raise_record_not_found!(klass:, key:, id:)
|
|
76
|
+
raise ActiveRecord::RecordNotFound.new("Couldn't find #{klass} with '#{key}'='#{id}'", klass.name, key, Array.wrap(id))
|
|
77
|
+
end
|
|
74
78
|
end
|
|
75
79
|
|
|
76
80
|
ActiveSupport.on_load(:action_controller) do
|
data/rails_settlement.gemspec
CHANGED
|
@@ -31,8 +31,8 @@ Gem::Specification.new do |spec|
|
|
|
31
31
|
spec.require_paths = ["lib"]
|
|
32
32
|
|
|
33
33
|
# Uncomment to register a new dependency of your gem
|
|
34
|
-
spec.add_dependency "activerecord", ">=
|
|
35
|
-
spec.add_dependency "activesupport", ">=
|
|
34
|
+
spec.add_dependency "activerecord", ">= 6.0"
|
|
35
|
+
spec.add_dependency "activesupport", ">= 6.0"
|
|
36
36
|
|
|
37
37
|
# For more information and examples about making a new gem, check out our
|
|
38
38
|
# guide at: https://bundler.io/guides/creating_gem.html
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rails_settlement
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tejas
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2024-
|
|
11
|
+
date: 2024-05-19 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activerecord
|
|
@@ -16,28 +16,28 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - ">="
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '
|
|
19
|
+
version: '6.0'
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - ">="
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '
|
|
26
|
+
version: '6.0'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: activesupport
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
31
|
- - ">="
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: '
|
|
33
|
+
version: '6.0'
|
|
34
34
|
type: :runtime
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
38
|
- - ">="
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: '
|
|
40
|
+
version: '6.0'
|
|
41
41
|
description: A simple way to initialize objects in rails controllers using callbacks
|
|
42
42
|
and ruby magic!
|
|
43
43
|
email:
|