methodist 1.2.0 → 1.2.2

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
  SHA256:
3
- metadata.gz: db3327d005f3ea2e87b22fa4db36cd4a1ebf6183018c4bb3e0f87635f6e1bd69
4
- data.tar.gz: 53582ce20974c015108001d61c82f82119709208702c423061aa1591ecae678c
3
+ metadata.gz: da5a8eb24c48c7014ad69d52327f570cddf39533a93c775f7e468cce9678e0e4
4
+ data.tar.gz: 4377bb0f3918a9b0023156d8214d17940c6116fbd8bc1a586e0bdf4f6e039dfb
5
5
  SHA512:
6
- metadata.gz: 82bc591f3fba95fa0237c194819891ea8f77c4d4fdc15e1164e8faa00f7201073136e2cf99a2f94d95f384133bfaaf4b80506d6998aa8075faf71e9e1b360f7b
7
- data.tar.gz: a200d6b5ac5c21ce92a937de325780663fcba50b5a1c1263c880aab63087e54c8d3d65b21579e844b2d5c831a6c2319fb0e4334314cf7f02aecb854e91053a90
6
+ metadata.gz: d04e17ad253635eb6a6cc789564b04d344725e18ef962a77e10a0139207a3d51719731d443c98f11b9ecf279086f8f153309f1effa636f882d2439684afa141a
7
+ data.tar.gz: 979ae625ef691502453aa6e5a0b56354772f7216b2452ec3ad135da289217c3e84620f3e096e9314d1cdc1f0d67649ab7e21c3f4d51f47f245653a0df869c2b5
@@ -66,6 +66,7 @@ class Methodist::Builder < Methodist::Pattern
66
66
  set_proc_to_const(proc, attr_name) if proc
67
67
 
68
68
  define_method("#{attr_name}=") do |val|
69
+ val = options[:prepare].call(val) if options[:prepare]
69
70
  instance_variable_set("@#{attr_name}".to_sym, val)
70
71
  return val if valid_attr?(attr_name)
71
72
  instance_variable_set("@#{attr_name}".to_sym, nil)
@@ -145,8 +145,10 @@ class Methodist::Interactor < Methodist::Pattern
145
145
  def validate(input)
146
146
  input = {} unless input
147
147
  raise InputClassError, 'If you want to use custom #validate, you have to pass a hash to an interactor' unless input.is_a?(Hash)
148
+
148
149
  validator = contract_class ? contract_class : input_schema
149
150
  raise ValidatorDefinitionError, 'you must define schema via #schema OR define contract via #contract' unless validator
151
+
150
152
  @validation_result = validator.call(input)
151
153
  return Success(validation_result.to_h) if validation_result.success?
152
154
  Failure(failure_validation_value)
@@ -178,4 +180,5 @@ class Methodist::Interactor < Methodist::Pattern
178
180
  class InputClassError < StandardError; end
179
181
  class DryValidationVersionError < StandardError; end
180
182
  class ContractDefinitionError < StandardError; end
183
+ class SchemaDefinitionError < StandardError; end
181
184
  end
@@ -1,3 +1,3 @@
1
1
  module Methodist
2
- VERSION = '1.2.0'
2
+ VERSION = '1.2.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: methodist
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergey Nesterov
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-11 00:00:00.000000000 Z
11
+ date: 2022-12-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0.13'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rbs
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 2.8.2
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 2.8.2
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: sqlite3
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -155,7 +169,7 @@ homepage: https://github.com/QNester/methodist
155
169
  licenses:
156
170
  - MIT
157
171
  metadata: {}
158
- post_install_message:
172
+ post_install_message:
159
173
  rdoc_options: []
160
174
  require_paths:
161
175
  - lib
@@ -170,8 +184,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
170
184
  - !ruby/object:Gem::Version
171
185
  version: '0'
172
186
  requirements: []
173
- rubygems_version: 3.0.8
174
- signing_key:
187
+ rubygems_version: 3.1.2
188
+ signing_key:
175
189
  specification_version: 4
176
190
  summary: Gem for Ruby on Rails created to stop chaos in your buisness logic.
177
191
  test_files: []