use_cases 0.3.4 → 0.3.8

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: b23fbdabf2ed8296b4d97887efd8ad0397f8404e04a25416b8325fd2de4d9157
4
- data.tar.gz: bc7d2ed3d1f051e130144886354f4a92ef22eb5cdc9afa19255d16ead5f2fc45
3
+ metadata.gz: ad9722f48d9d6f073a9699cb042c246d935994b4384e340e3b985c35ea6a697b
4
+ data.tar.gz: 8d3cc6daeef1b64fb86a96a9e6ff13a3b95ef328ff2a4e453696cae0724a1572
5
5
  SHA512:
6
- metadata.gz: 04ab7eeacb1b52422519df50d6ed34bea32fe8ca69488f0f2247f177354610e5c30ba83f9ffde0475a6a374cf7d4f5808c486d1450b2091404c1e86aa9bd56e9
7
- data.tar.gz: a0496ea6b528412ac49711044914c2c76817ae131d3569013a30cd0816f6ce9236f4155a0d2218916e5b576a2f074ba094e971fdacba25f5b7ea8f31a4f3751c
6
+ metadata.gz: aefef04cfa79694d593848a6c245ad3d282416fdf28de6a934581f8fa15bfadf1faf5fccf1624a272b997473619af36841464feb8b1f26b6329ee8333a688e4b
7
+ data.tar.gz: 00bb31d99dfd4e9f1d98d99778b1263e4d32949dc5270af41f78d19dba6a460afeba44797219984dcbe964c516c150e2c0ee1db1392645760de14a7599ae2876
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- use_cases (0.3.4)
4
+ use_cases (0.3.7)
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.
@@ -9,7 +9,7 @@ RSpec::Matchers.define(:be_failure_with_code) do |expected_code|
9
9
  end
10
10
 
11
11
  failure_message do |test_subject|
12
- if text_subject.failure?
12
+ if test_subject.failure?
13
13
  "the use case was expected to fail with code #{expected_code} but it returned #{test_subject.failure.first}"
14
14
  else
15
15
  "the use case was expected to fail with code #{expected_code} but it did not fail"
@@ -55,13 +55,13 @@ 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
- when String then object.send(options[:with])
64
+ when String, Symbol then object.send(options[:with])
65
65
  else options[:with]
66
66
  end
67
67
  end
@@ -61,9 +61,14 @@ module UseCases
61
61
  def validate(params, current_user)
62
62
  return Failure([:validation_error, "*params* must be a hash."]) unless params.respond_to?(:merge)
63
63
 
64
- validation = contract.call(params.merge(current_user: current_user))
64
+ validation = contract.call(params)
65
65
 
66
- validation.success? ? Success(validation.to_h) : Failure([:validation_error, validation.errors.to_h])
66
+ if validation.success?
67
+ params.merge!(validation.to_h)
68
+ Success(validation.to_h)
69
+ else
70
+ Failure([:validation_error, validation.errors.to_h])
71
+ end
67
72
  end
68
73
 
69
74
  def contract
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module UseCases
4
- VERSION = "0.3.4"
4
+ VERSION = "0.3.8"
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.4
4
+ version: 0.3.8
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-11-25 00:00:00.000000000 Z
11
+ date: 2021-12-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport