use_cases 0.3.1 → 0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7b4ebb9b33b42faeacd926b68ad103ec38773f7532f42dc125327adcf247dd13
4
- data.tar.gz: 0afebb1d549e5990f7fa4d910def09bac3773fcf8b4171742fb6d6f111a745b3
3
+ metadata.gz: 0c255a9eb076badd633005c245163cbbbbd6a7f88c499e1802a8f46c1027d7d3
4
+ data.tar.gz: 853ccd683b1a558b55af72c4a69785ed928334ec8b28aa504d4512b3ac844fb4
5
5
  SHA512:
6
- metadata.gz: 981827ca7f45383a32c2c015daf559665fe790c4481f02668f460b26e7866a354a6e6a5630d92a20c988d069eece47bdcb62fdb6548731cd19f43c76cd062b23
7
- data.tar.gz: e21e32a5c9aae5f8b3b1b0235b85f50385aeaf058cf2c458fcb44b206ba973bc9071e5891d3827c5cc558c1800b3a4c9da697de05125298206f90a2c52c02575
6
+ metadata.gz: a844007db36260f84d7946d42967493d24677b6b164fde954444eed12985255b161b15d67883b4ffdf87297740622bfdf721132842b68b7d362d273f70c5e935
7
+ data.tar.gz: 173a36fd17694b838a4d74f56cb1a3bd1014333280a39d1164f952ae82562e80991b0774b1cc34532e956f45698c66cd855cb3a64314177e6e5335217035fa3d
data/.gitignore CHANGED
@@ -9,4 +9,5 @@
9
9
 
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
- .byebug_history
12
+ .byebug_history
13
+ *.gem
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- use_cases (0.2.5)
4
+ use_cases (0.3.5)
5
5
  activesupport
6
6
  dry-events
7
7
  dry-matcher
data/README.md CHANGED
@@ -4,6 +4,8 @@
4
4
 
5
5
  # UseCases
6
6
 
7
+ ## Currently Unstable! Use at your own risk.
8
+
7
9
  `UseCases` is a gem based on the [dry-transaction](https://dry-rb.org/gems/dry-transaction/) DSL that implements macros commonly used internally by Ring Twice.
8
10
 
9
11
  `UseCases` does not however use `dry-transaction` behind the scenes. Instead it relies on other `dry` libraries like [dry-validation](https://dry-rb.org/gems/dry-validation/), [dry-events](https://dry-rb.org/gems/dry-validation/) and [dry-monads](https://dry-rb.org/gems/dry-validation/) to implement a DSL that can be flexible enough for our needs.
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "byebug"
4
-
5
3
  module UseCases
6
4
  module Notifications
7
5
  def self.included(base)
@@ -5,7 +5,7 @@ require "rspec"
5
5
  RSpec::Matchers.define(:be_failure_with_code) do |expected_code|
6
6
  match do |test_subject|
7
7
  expect(test_subject.failure?).to be true
8
- expect(test_subject.failure.first).to eq expected_code
8
+ expect(test_subject.failure.first).to eql expected_code
9
9
  end
10
10
 
11
11
  failure_message do |test_subject|
@@ -20,7 +20,7 @@ end
20
20
  RSpec::Matchers.define(:be_failure_with_payload) do |expected_result|
21
21
  match do |test_subject|
22
22
  expect(test_subject.failure?).to be true
23
- expect(test_subject.failure.last).to eq expected_result
23
+ expect(test_subject.failure.last).to eql expected_result
24
24
  end
25
25
 
26
26
  failure_message do |test_subject|
@@ -35,7 +35,7 @@ end
35
35
  RSpec::Matchers.define(:be_failure_with) do |*expected_failure|
36
36
  match do |test_subject|
37
37
  expect(test_subject.failure?).to be true
38
- expect(test_subject.failure).to eq expected_failure
38
+ expect(test_subject.failure).to eql expected_failure
39
39
  end
40
40
 
41
41
  failure_message do |test_subject|
@@ -50,7 +50,7 @@ end
50
50
  RSpec::Matchers.define(:be_successful_with) do |expected_result|
51
51
  match do |test_subject|
52
52
  expect(test_subject.success?).to be true
53
- expect(test_subject.success).to eq expected_result
53
+ expect(test_subject.success).to eql expected_result
54
54
  end
55
55
 
56
56
  failure_message do |test_subject|
@@ -55,14 +55,14 @@ module UseCases
55
55
  end
56
56
 
57
57
  def callable_proc
58
- callable_object.method(callable_method)
58
+ callable_object.method(callable_method).to_proc
59
59
  end
60
60
 
61
61
  def callable_object
62
62
  case options[:with]
63
63
  when NilClass, FalseClass then object
64
64
  when String then object.send(options[:with])
65
- else options[:with]
65
+ else send(options[:with])
66
66
  end
67
67
  end
68
68
 
@@ -12,8 +12,8 @@ module UseCases
12
12
  prev_result = previous_step_result.value
13
13
  raise InvalidReturnValue, "The return value should not be a Monad." if result.is_a?(Dry::Monads::Result)
14
14
 
15
- failure_code = options[:failure] || :check_failure
16
- failure_message = options[:failure_message] || "Failed"
15
+ failure_code = options[:failure] || :unauthorized
16
+ failure_message = options[:failure_message] || "Not Authorized"
17
17
 
18
18
  result ? Success(prev_result) : Failure([failure_code, failure_message])
19
19
  end
@@ -6,7 +6,7 @@ module UseCases
6
6
  def do_call(*base_args)
7
7
  args = [object.class.name, name.to_s, *base_args]
8
8
  args = ::UseCases::StepActiveJobAdapter.serialize_step_arguments(args)
9
- byebug
9
+
10
10
  job_options = options.slice(:queue, :wait, :wait_until, :priority)
11
11
 
12
12
  ::UseCases::StepActiveJobAdapter.set(job_options).perform_later(*args)
@@ -13,7 +13,7 @@ module UseCases
13
13
 
14
14
  Success(result)
15
15
  rescue options[:catch] || StandardError => e
16
- Failure([options[:failure], e.message])
16
+ Failure([options[:failure], options[:failure_message] || e.message])
17
17
  end
18
18
  end
19
19
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module UseCases
4
- VERSION = "0.3.1"
4
+ VERSION = "0.3.5"
5
5
  end
data/lib/use_cases.rb CHANGED
@@ -4,4 +4,8 @@ require_relative "use_case"
4
4
  require_relative "use_cases/version"
5
5
  require_relative "use_cases/base"
6
6
 
7
- module UseCases; end
7
+ module UseCases
8
+ def self.register_type(type_name, klass)
9
+
10
+ end
11
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: use_cases
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ring Twice
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-10-26 00:00:00.000000000 Z
11
+ date: 2021-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport