trailblazer 2.0.0.beta2 → 2.0.0.beta3

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: c73755bd284523c496d97f90e637048d778a4233
4
- data.tar.gz: 8c380418456b199836576b6d6cb78611d5e8ca73
3
+ metadata.gz: 36d5743aefbaa5f3164a9d247adfcef5a4acd3ad
4
+ data.tar.gz: 4d263f2e11657140bccbd98e90915896b00d39db
5
5
  SHA512:
6
- metadata.gz: 8aee8a0a4ccfa11d016504d269e7f9248e58696ae508c15031b5f59a0e35f647a68d940f1244b150d5b05a8533e9dab05c47bbe11a1d07ae79a315d949a2ff61
7
- data.tar.gz: 7d6086b907f98b3d53bf152d1a72ef47d71bdbb5482ec38f6096cf682bc3e44f1faa83a35b30c7700e79936181ade80838d08190981d6355a9dc62e4a2993a61
6
+ metadata.gz: 92afde635725edbf16f2c3705fc9f3e1462ab955c5fbb273754f58fc1c79bff1916cb5ad4aeb319784d6a1589b8dc1371283469b74a540922e1bfeda2730f3f7
7
+ data.tar.gz: e323a24a729b87ae7fcb50ecc8a2483c237f0f7f2edf0e6025185d8787b26abda307d176f3b0b884fd642d04dc0c958e01b1e8ba2b60cdd6b562707569829b33
data/CHANGES.md CHANGED
@@ -102,6 +102,10 @@ You can now inject the following objects via `::call`:
102
102
 
103
103
  * You can't call `Create.().contract` anymore. The contract instance(s) are available through the `Result` object.
104
104
 
105
+ # 2.0.0.beta3
106
+
107
+ * New, very slick keyword arguments for steps.
108
+
105
109
  # 2.0.0.beta2
106
110
 
107
111
  * Removed `Operation::Controller`.
data/Gemfile CHANGED
@@ -20,7 +20,7 @@ gem "dry-matcher"
20
20
  gem "dry-validation"
21
21
 
22
22
 
23
- gem "trailblazer-operation"#, path: "../operation"
23
+ # gem "trailblazer-operation", path: "../operation"
24
24
  # gem "pipetree", path: "../pipetree"
25
25
 
26
26
  gem "minitest-line"
@@ -1,8 +1,10 @@
1
1
  class Trailblazer::Operation
2
2
  module Rescue
3
- def self.import!(_operation, import, *exceptions, handler:->(*){}, &block)
3
+ Noop = ->(*) {}
4
+
5
+ def self.import!(_operation, import, *exceptions, handler: Noop, &block)
4
6
  exceptions = [StandardError] unless exceptions.any?
5
- handler = Pipetree::DSL::Option.(handler)
7
+ handler = Option.(handler)
6
8
 
7
9
  rescue_block = ->(options, operation, *, &nested_pipe) {
8
10
  begin
@@ -1,3 +1,3 @@
1
1
  module Trailblazer
2
- VERSION = "2.0.0.beta2"
2
+ VERSION = "2.0.0.beta3"
3
3
  end
@@ -44,3 +44,57 @@ class DndTest < Minitest::Spec
44
44
  self.< Wrap
45
45
  end
46
46
  end
47
+
48
+ class DocsResultTest < Minitest::Spec
49
+ Song = Struct.new(:id, :title, :created_by) do
50
+ def save; true; end
51
+ end
52
+
53
+ #:step-options
54
+ class Song::Create < Trailblazer::Operation
55
+ step :model!
56
+ step :assign!
57
+ consider :validate!
58
+
59
+ def model!(options, current_user:, **)
60
+ options["model"] = Song.new
61
+ options["model"].created_by = current_user
62
+ end
63
+
64
+ def assign!(*, params:, model:, **)
65
+ model.title= params[:title]
66
+ end
67
+
68
+ #:step-val
69
+ def validate!(options, model:, **)
70
+ options["result.validate"] = ( model.created_by && model.title )
71
+ end
72
+ #:step-val end
73
+ end
74
+ #:step-options end
75
+
76
+ it do
77
+ current_user = Struct.new(:email).new("nick@trailblazer.to")
78
+ #:step-res
79
+ result = Song::Create.({ title: "Roxanne" }, "current_user" => current_user)
80
+
81
+ result["model"] #=> #<Song title="Roxanne", "created_by"=<User ...>
82
+ result["result.validate"] #=> true
83
+ #:step-res end
84
+
85
+ result.inspect("current_user", "model").must_equal %{<Result:true [#<struct email=\"nick@trailblazer.to\">, #<struct DocsResultTest::Song id=nil, title="Roxanne", created_by=#<struct email=\"nick@trailblazer.to\">>] >}
86
+
87
+ #:step-binary
88
+ result.success? #=> true
89
+ result.failure? #=> falsee
90
+ #:step-binary end
91
+
92
+ #:step-dep
93
+ result["current_user"] #=> <User ...>
94
+ #:step-dep end
95
+
96
+ #:step-inspect
97
+ result.inspect("current_user", "model") #=> "<Result:true [#<User email=\"nick@tra... "
98
+ #:step-inspect end
99
+ end
100
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trailblazer
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.beta2
4
+ version: 2.0.0.beta3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Sutterer