metaractor 1.2.0 → 1.2.1

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: fc495c71ac16ac1b8a355d83849f7f27b9980acb4f7fb36cf8da50773e73c4fc
4
- data.tar.gz: 015a5f2abe0b5d1bd62ae5e685ec509f8b46ad29e4d2fa3dd5e9d98aae4db461
3
+ metadata.gz: 26bc406252dfc7f8839f49ca5ee2a4a85cb1961db82c0a0a24928e964010ec17
4
+ data.tar.gz: b1412660d447cba69a18ffa3a290942de9339751abf2aebbd737b8326b7d7b57
5
5
  SHA512:
6
- metadata.gz: 781c25b93c7b3cc8c645218ba0f7971389d86a1129ad1a62bd9930eb28b6a3413736917135c3bc6e8b4e803a7ad1664e12f7dfc6d133fa4c325e25696de75e36
7
- data.tar.gz: fbbb9d96afed276d4a187255745b069dd7a18001e351934724d1b9122807300a844839ddee43112e74691b7ef314745de14b70b248d835ca31d3cdee20015908
6
+ metadata.gz: 02b54f2d308bbac395167a086aecbcca66bd2780a9a13871243ca150789b36d4f0717aec967b3fb5201e07e9ee9324b3a3ecfde203c2dd8bd3c15bc8d0b2ae22
7
+ data.tar.gz: ce8dda0f8c1a366dc311db0d32e7526d9fbf7bef45d23a3c77c49b67f591c06084f8a6a9ab1aa43063c002f42aaf1f1eecb93be10968b4803971cc6bc142a418
data/Dockerfile CHANGED
@@ -1,4 +1,4 @@
1
- FROM ruby:2.5.1-alpine
1
+ FROM ruby:2.6.5-alpine
2
2
  MAINTAINER Ryan Schlesinger <ryan@outstand.com>
3
3
 
4
4
  RUN addgroup -g 1000 -S metaractor && \
data/README.md CHANGED
@@ -74,6 +74,14 @@ As optional parameters have no enforcement, they are merely advisory.
74
74
  optional :enable_logging
75
75
  ```
76
76
 
77
+ ### Skipping Blank Parameter Removal
78
+ By default Metaractor removes blank values that are passed in. You may skip this behavior on a per-parameter basis:
79
+ ```ruby
80
+ allow_blank :name
81
+ ```
82
+
83
+ You may check to see if a parameter exists via `context.has_key?`.
84
+
77
85
  ### Custom Validation
78
86
  Metaractor supports doing custom validation before any user supplied before_hooks run.
79
87
  ```ruby
@@ -0,0 +1,9 @@
1
+ module Metaractor
2
+ module ContextHasKey
3
+ def has_key?(key)
4
+ @table.has_key?(key.to_sym)
5
+ end
6
+ end
7
+ end
8
+
9
+ Interactor::Context.send(:include, Metaractor::ContextHasKey)
@@ -8,6 +8,7 @@ module Metaractor
8
8
  class << self
9
9
  attr_writer :_required_parameters
10
10
  attr_writer :_optional_parameters
11
+ attr_writer :_allow_blank
11
12
  end
12
13
 
13
14
  before :remove_blank_values
@@ -33,6 +34,14 @@ module Metaractor
33
34
  self._optional_parameters += params
34
35
  end
35
36
 
37
+ def _allow_blank
38
+ @_allow_blank ||= []
39
+ end
40
+
41
+ def allow_blank(*params)
42
+ self._allow_blank += params
43
+ end
44
+
36
45
  def validate_parameters(*hooks, &block)
37
46
  hooks << block if block
38
47
  hooks.each {|hook| validate_hooks.push(hook) }
@@ -46,6 +55,8 @@ module Metaractor
46
55
  def remove_blank_values
47
56
  to_delete = []
48
57
  context.each_pair do |k,v|
58
+ next if self.class._allow_blank.include?(k)
59
+
49
60
  # The following regex is borrowed from Rails' String#blank?
50
61
  to_delete << k if (v.is_a?(String) && /\A[[:space:]]*\z/ === v) || v.nil?
51
62
  end
@@ -1,3 +1,3 @@
1
1
  module Metaractor
2
- VERSION = "1.2.0"
2
+ VERSION = "1.2.1"
3
3
  end
data/lib/metaractor.rb CHANGED
@@ -7,6 +7,7 @@ require 'metaractor/run_with_context'
7
7
  require 'metaractor/context_validity'
8
8
  require 'metaractor/chain_failures'
9
9
  require 'metaractor/fail_from_context'
10
+ require 'metaractor/context_has_key'
10
11
 
11
12
  module Metaractor
12
13
  def self.included(base)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metaractor
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Schlesinger
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-12-10 00:00:00.000000000 Z
11
+ date: 2020-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: interactor
@@ -85,6 +85,7 @@ files:
85
85
  - lib/metaractor.rb
86
86
  - lib/metaractor/chain_failures.rb
87
87
  - lib/metaractor/context_errors.rb
88
+ - lib/metaractor/context_has_key.rb
88
89
  - lib/metaractor/context_validity.rb
89
90
  - lib/metaractor/errors.rb
90
91
  - lib/metaractor/fail_from_context.rb
@@ -111,8 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
112
  - !ruby/object:Gem::Version
112
113
  version: '0'
113
114
  requirements: []
114
- rubyforge_project:
115
- rubygems_version: 2.7.7
115
+ rubygems_version: 3.0.3
116
116
  signing_key:
117
117
  specification_version: 4
118
118
  summary: Adds parameter validation and error control to interactor