trailblazer-finder 0.80.1 → 0.90.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/trailblazer/finder/version.rb +1 -1
- data/lib/trailblazer/operation/finder.rb +44 -42
- data/trailblazer-finder.gemspec +2 -2
- metadata +3 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c3605d464db4d05bd07e54aec870bd62820657704a730ebc02d11f904dcd964
|
4
|
+
data.tar.gz: e0c677b1cf39def27bef24b5787cf0cc6a475afb9adf227baa77315ee447208b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 251cf565e7ca50200c70a997bbbe8c96d28232b28d8bd8001129612194ee2065f57b6198b965cb60f19420f988ad1af17cdcd50c4ad23a50d6eff2241d4a2845
|
7
|
+
data.tar.gz: dcad67e86a906c097f00b88b6b051b296819287a1401db159c401121142e794028a0a0406b8836fc74f590c368ac6a21045f39ed869d36e7b1f6642495c8ae91
|
@@ -1,55 +1,57 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
class Finder
|
15
|
-
def call(ctx, **options)
|
16
|
-
builder = Finder::Builder.new
|
17
|
-
ctx[:finder] = finder = builder.call(options, options[:params])
|
18
|
-
ctx[:model] = finder # Don't like it, but somehow it's needed if contracts are loaded
|
19
|
-
ctx[:"result.finder"] = Trailblazer::Operation::Result.new(!finder.nil?, {})
|
20
|
-
|
21
|
-
ctx[:"result.finder"].success?
|
1
|
+
module Trailblazer
|
2
|
+
class Operation
|
3
|
+
def self.Finder(finder_class, action = nil, entity = nil)
|
4
|
+
task = Trailblazer::Activity::TaskBuilder::Binary(Finder.new)
|
5
|
+
injections = [
|
6
|
+
:params,
|
7
|
+
{:"finder.class" => ->(*) { finder_class }},
|
8
|
+
{:"finder.entity" => ->(*) { entity }},
|
9
|
+
{:"finder.action" => ->(*) { action }}
|
10
|
+
]
|
11
|
+
|
12
|
+
{task: task, id: "finder.build", inject: injections}
|
22
13
|
end
|
23
14
|
|
24
|
-
class
|
25
|
-
def call(
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
15
|
+
class Finder
|
16
|
+
def call(ctx, **options)
|
17
|
+
builder = Finder::Builder.new
|
18
|
+
ctx[:finder] = finder = builder.call(options, options[:params])
|
19
|
+
ctx[:model] = finder # Don't like it, but somehow it's needed if contracts are loaded
|
20
|
+
ctx[:"result.finder"] = Trailblazer::Operation::Result.new(!finder.nil?, {})
|
30
21
|
|
31
|
-
|
22
|
+
ctx[:"result.finder"].success?
|
32
23
|
end
|
33
24
|
|
34
|
-
|
25
|
+
class Builder
|
26
|
+
def call(options, params)
|
27
|
+
finder_class = options[:"finder.class"]
|
28
|
+
entity = options[:"finder.entity"]
|
29
|
+
action = options[:"finder.action"]
|
30
|
+
action = :all unless %i[all single].include?(action)
|
35
31
|
|
36
|
-
|
37
|
-
|
38
|
-
end
|
32
|
+
send("#{action}!", finder_class, entity, params, options[:"finder.action"])
|
33
|
+
end
|
39
34
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
finder_class.new(params: params)
|
44
|
-
else
|
45
|
-
finder_class.new(entity: entity, params: params).result.first
|
35
|
+
private
|
36
|
+
|
37
|
+
def all!(finder_class, entity, params, *)
|
38
|
+
finder_class.new(entity: entity, params: params)
|
46
39
|
end
|
47
|
-
end
|
48
40
|
|
49
|
-
|
50
|
-
|
41
|
+
def single!(finder_class, entity, params, *)
|
42
|
+
apply_id(params)
|
43
|
+
if entity.nil?
|
44
|
+
finder_class.new(params: params).result.first
|
45
|
+
else
|
46
|
+
finder_class.new(entity: entity, params: params).result.first
|
47
|
+
end
|
48
|
+
end
|
51
49
|
|
52
|
-
|
50
|
+
def apply_id(params)
|
51
|
+
return if params[:id].nil?
|
52
|
+
|
53
|
+
params[:id_eq] = params[:id]
|
54
|
+
end
|
53
55
|
end
|
54
56
|
end
|
55
57
|
end
|
data/trailblazer-finder.gemspec
CHANGED
@@ -14,12 +14,12 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.homepage = "http://trailblazer.to"
|
15
15
|
spec.license = "LGPL-3.0"
|
16
16
|
spec.files = Dir.glob("lib/**/*")
|
17
|
-
spec.files
|
17
|
+
spec.files << ["trailblazer-finder.gemspec"]
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
21
|
spec.add_dependency "dry-types", ">= 1.0.0"
|
22
|
-
spec.add_dependency "trailblazer-activity", ">= 0.
|
22
|
+
spec.add_dependency "trailblazer-activity", ">= 0.13.0"
|
23
23
|
|
24
24
|
spec.add_development_dependency "activerecord"
|
25
25
|
spec.add_development_dependency "bundler"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trailblazer-finder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.90.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Sutterer
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2022-06-
|
13
|
+
date: 2022-06-07 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: dry-types
|
@@ -31,9 +31,6 @@ dependencies:
|
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
32
32
|
requirements:
|
33
33
|
- - ">="
|
34
|
-
- !ruby/object:Gem::Version
|
35
|
-
version: 0.10.0
|
36
|
-
- - "<"
|
37
34
|
- !ruby/object:Gem::Version
|
38
35
|
version: 0.13.0
|
39
36
|
type: :runtime
|
@@ -41,9 +38,6 @@ dependencies:
|
|
41
38
|
version_requirements: !ruby/object:Gem::Requirement
|
42
39
|
requirements:
|
43
40
|
- - ">="
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: 0.10.0
|
46
|
-
- - "<"
|
47
41
|
- !ruby/object:Gem::Version
|
48
42
|
version: 0.13.0
|
49
43
|
- !ruby/object:Gem::Dependency
|
@@ -324,7 +318,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
324
318
|
- !ruby/object:Gem::Version
|
325
319
|
version: '0'
|
326
320
|
requirements: []
|
327
|
-
rubygems_version: 3.2.
|
321
|
+
rubygems_version: 3.2.22
|
328
322
|
signing_key:
|
329
323
|
specification_version: 4
|
330
324
|
summary: Trailblazer based finder objects. It is designed to be used on its own as
|