ree_lib 1.3.4 → 1.3.5
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/Gemfile +3 -0
- data/Gemfile.lock +11 -4
- data/lib/ree_lib/packages/ree_actions/package/ree_actions/dsl.rb +8 -33
- data/lib/ree_lib/packages/ree_actions/package/ree_actions/method_plugin.rb +48 -0
- data/lib/ree_lib/packages/ree_actions/spec/ree_actions/dsl_spec.rb +18 -1
- data/lib/ree_lib/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1d2bd58c6bd8e2cb3149a2aee091cb78eaabc26926b85f2ff59bffd1d672d227
|
|
4
|
+
data.tar.gz: 0a7436a5fcf432aa79b93eaa28411749807cd104cbd0a3a19848f77338cca889
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bdd2465fc1e0113e515c9bb729938623087da55512c29275f85cf7bd11d7fe9bad9cd2a23c036b47d395b16478616d5c3cd10c3d9e6b5ffc451159ae8d9c6ea6
|
|
7
|
+
data.tar.gz: e0b7d0b4191c9bc0c5dea024937685b8fe9b879cb4d974e16c9a854d3aaaca8ebf26f2d6face2b8ff178643bfdba1244c226d73f7b45e2b70446a5ce12ba014c
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: ../ree
|
|
3
|
+
specs:
|
|
4
|
+
ree (1.2.7)
|
|
5
|
+
base64
|
|
6
|
+
commander (~> 5.0.0)
|
|
7
|
+
logger (~> 1.6.5)
|
|
8
|
+
|
|
1
9
|
PATH
|
|
2
10
|
remote: .
|
|
3
11
|
specs:
|
|
4
|
-
ree_lib (1.3.
|
|
12
|
+
ree_lib (1.3.5)
|
|
5
13
|
bigdecimal (~> 3.1.9)
|
|
6
14
|
binding_of_caller (~> 1.0.1)
|
|
7
15
|
i18n (~> 1.14.7)
|
|
@@ -17,6 +25,7 @@ GEM
|
|
|
17
25
|
specs:
|
|
18
26
|
addressable (2.8.7)
|
|
19
27
|
public_suffix (>= 2.0.2, < 7.0)
|
|
28
|
+
base64 (0.3.0)
|
|
20
29
|
bigdecimal (3.1.9)
|
|
21
30
|
binding_of_caller (1.0.1)
|
|
22
31
|
debug_inspector (>= 1.2.0)
|
|
@@ -58,9 +67,6 @@ GEM
|
|
|
58
67
|
rack (>= 1.3)
|
|
59
68
|
rainbow (3.1.1)
|
|
60
69
|
rake (13.2.1)
|
|
61
|
-
ree (1.1.2)
|
|
62
|
-
commander (~> 5.0.0)
|
|
63
|
-
logger (~> 1.6.5)
|
|
64
70
|
rexml (3.3.6)
|
|
65
71
|
strscan
|
|
66
72
|
roda (3.88.0)
|
|
@@ -108,6 +114,7 @@ DEPENDENCIES
|
|
|
108
114
|
pg (~> 1.5.9)
|
|
109
115
|
rack-test
|
|
110
116
|
rake (~> 13.0)
|
|
117
|
+
ree!
|
|
111
118
|
ree_lib!
|
|
112
119
|
roda (~> 3.88.0)
|
|
113
120
|
rollbar (~> 3.6.0)
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
package_require("ree_mapper/errors/type_error")
|
|
3
3
|
package_require("ree_mapper/errors/coercion_error")
|
|
4
|
+
package_require("ree_actions/method_plugin")
|
|
4
5
|
|
|
5
6
|
module ReeActions
|
|
6
7
|
module DSL
|
|
7
8
|
def self.included(base)
|
|
8
9
|
base.extend(ClassMethods)
|
|
10
|
+
base.extend(Ree::MethodAddedHook)
|
|
9
11
|
base.include(ReeMapper::DSL)
|
|
10
12
|
base.include(Ree::Inspectable)
|
|
11
13
|
end
|
|
12
14
|
|
|
13
15
|
def self.extended(base)
|
|
14
16
|
base.extend(ClassMethods)
|
|
17
|
+
base.extend(Ree::MethodAddedHook)
|
|
15
18
|
base.include(ReeMapper::DSL)
|
|
16
19
|
end
|
|
17
20
|
|
|
@@ -31,39 +34,11 @@ module ReeActions
|
|
|
31
34
|
|
|
32
35
|
Ree.container.compile(dsl.package, name)
|
|
33
36
|
end
|
|
34
|
-
|
|
35
|
-
def method_added(method_name)
|
|
36
|
-
return super if method_name != :call
|
|
37
|
-
|
|
38
|
-
if @__original_call_defined
|
|
39
|
-
remove_instance_variable(:@__original_call_defined)
|
|
40
|
-
return
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
@__original_call_defined = true
|
|
44
|
-
|
|
45
|
-
alias_method(:__original_call, :call)
|
|
46
|
-
|
|
47
|
-
define_method :call do |user_access, attrs, **opts, &proc|
|
|
48
|
-
if self.class.const_defined?(:ActionCaster)
|
|
49
|
-
caster = self.class.const_get(:ActionCaster)
|
|
50
|
-
|
|
51
|
-
if !caster.respond_to?(:cast)
|
|
52
|
-
raise ArgumentError.new("ActionCaster does not respond to `cast` method")
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
attrs = begin
|
|
56
|
-
caster.cast(attrs)
|
|
57
|
-
rescue ReeMapper::TypeError, ReeMapper::CoercionError => e
|
|
58
|
-
raise ReeActions::ParamError, e.message
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
__original_call(user_access, attrs, **opts, &proc)
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
nil
|
|
66
|
-
end
|
|
67
37
|
end
|
|
68
38
|
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# Register the method plugin if the plugin system is available
|
|
42
|
+
if defined?(Ree) && Ree.respond_to?(:register_method_added_plugin)
|
|
43
|
+
Ree.register_method_added_plugin(ReeActions::MethodPlugin)
|
|
69
44
|
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class ReeActions::MethodPlugin
|
|
4
|
+
def self.active?
|
|
5
|
+
true # Always active when registered
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def initialize(method_name, is_class_method, target)
|
|
9
|
+
@method_name = method_name
|
|
10
|
+
@is_class_method = is_class_method
|
|
11
|
+
@target = target
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def call
|
|
15
|
+
# Only wrap :call method for classes that include ReeActions::DSL
|
|
16
|
+
return nil unless @method_name == :call
|
|
17
|
+
return nil unless ree_actions_class?
|
|
18
|
+
|
|
19
|
+
Proc.new do |instance, next_layer, *args, **kwargs, &block|
|
|
20
|
+
# ReeActions call signature: call(user_access, attrs, **opts, &block)
|
|
21
|
+
# First arg is user_access, second is attrs (the one to cast)
|
|
22
|
+
user_access, attrs, *rest_args = args
|
|
23
|
+
|
|
24
|
+
if instance.class.const_defined?(:ActionCaster)
|
|
25
|
+
caster = instance.class.const_get(:ActionCaster)
|
|
26
|
+
|
|
27
|
+
unless caster.respond_to?(:cast)
|
|
28
|
+
raise ArgumentError.new("ActionCaster does not respond to `cast` method")
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
attrs = begin
|
|
32
|
+
caster.cast(attrs)
|
|
33
|
+
rescue ReeMapper::TypeError, ReeMapper::CoercionError => e
|
|
34
|
+
raise ReeActions::ParamError, e.message
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# Call next layer with cast attrs
|
|
39
|
+
next_layer.call(user_access, attrs, *rest_args, **kwargs, &block)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
private
|
|
44
|
+
|
|
45
|
+
def ree_actions_class?
|
|
46
|
+
@target.included_modules.any? { |m| m.name == "ReeActions::DSL" }
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -25,11 +25,13 @@ RSpec.describe ReeActions::DSL, type: [:autoclean] do
|
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
before do
|
|
28
|
+
Ree.enable_benchmark_mode
|
|
28
29
|
Ree.enable_irb_mode
|
|
29
30
|
end
|
|
30
31
|
|
|
31
32
|
after do
|
|
32
33
|
Ree.disable_irb_mode
|
|
34
|
+
Ree.disable_benchmark_mode
|
|
33
35
|
end
|
|
34
36
|
|
|
35
37
|
it {
|
|
@@ -41,10 +43,24 @@ RSpec.describe ReeActions::DSL, type: [:autoclean] do
|
|
|
41
43
|
depends_on :ree_dao
|
|
42
44
|
end
|
|
43
45
|
|
|
46
|
+
class TestFn
|
|
47
|
+
include Ree::FnDSL
|
|
48
|
+
|
|
49
|
+
fn :test_fn
|
|
50
|
+
|
|
51
|
+
contract None = Integer
|
|
52
|
+
def call
|
|
53
|
+
1
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
44
57
|
class TestAction
|
|
45
58
|
include ReeActions::DSL
|
|
46
59
|
|
|
47
|
-
action :test_action
|
|
60
|
+
action :test_action do
|
|
61
|
+
benchmark
|
|
62
|
+
link :test_fn
|
|
63
|
+
end
|
|
48
64
|
|
|
49
65
|
ActionCaster = build_mapper.use(:cast) do
|
|
50
66
|
integer :user_id
|
|
@@ -52,6 +68,7 @@ RSpec.describe ReeActions::DSL, type: [:autoclean] do
|
|
|
52
68
|
|
|
53
69
|
contract Any, ActionCaster.dto(:cast) => Integer
|
|
54
70
|
def call(user_access, attrs)
|
|
71
|
+
test_fn
|
|
55
72
|
attrs[:user_id]
|
|
56
73
|
end
|
|
57
74
|
end
|
data/lib/ree_lib/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ree_lib
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.3.
|
|
4
|
+
version: 1.3.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ruslan Gatiyatov
|
|
8
8
|
bindir: exe
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2026-02-
|
|
10
|
+
date: 2026-02-09 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: ree
|
|
@@ -284,6 +284,7 @@ files:
|
|
|
284
284
|
- lib/ree_lib/packages/ree_actions/package/ree_actions.rb
|
|
285
285
|
- lib/ree_lib/packages/ree_actions/package/ree_actions/dsl.rb
|
|
286
286
|
- lib/ree_lib/packages/ree_actions/package/ree_actions/errors.rb
|
|
287
|
+
- lib/ree_lib/packages/ree_actions/package/ree_actions/method_plugin.rb
|
|
287
288
|
- lib/ree_lib/packages/ree_actions/spec/ree_actions/dsl_spec.rb
|
|
288
289
|
- lib/ree_lib/packages/ree_actions/spec/spec_helper.rb
|
|
289
290
|
- lib/ree_lib/packages/ree_array/.gitignore
|