pathway 0.0.13 → 0.0.14
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 +4 -4
- data/lib/pathway.rb +3 -3
- data/lib/pathway/plugins/dry_validation.rb +12 -5
- data/lib/pathway/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 85ddbb4a7f33859093dadc9c82d66fa2be92e4d1
|
4
|
+
data.tar.gz: ebf6d815197776cb0914be7e4926817cac2ab6e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d0072356edbbc5d505af0c1a4d9e584c62c28c0ddc1678a6d4e687c9d22746b88bc4eae2cd812f92f9b63cbe978e258e4cba6ceefc6cf5b68981f2f015fffcb
|
7
|
+
data.tar.gz: 4b5eb9be35ba2b9d77aa6831219081964c34891d1c7dda79e113fbad760622c97d52bec5cc518a43683a9ab5cb7905da9ae1656a684f4e001d99b52f7a378f5a
|
data/lib/pathway.rb
CHANGED
@@ -6,7 +6,7 @@ require 'pathway/result'
|
|
6
6
|
|
7
7
|
module Pathway
|
8
8
|
class Operation
|
9
|
-
def self.plugin(name)
|
9
|
+
def self.plugin(name, *args)
|
10
10
|
require "pathway/plugins/#{Inflecto.underscore(name)}" if name.is_a?(Symbol)
|
11
11
|
|
12
12
|
plugin = name.is_a?(Module) ? name : Plugins.const_get(Inflecto.camelize(name))
|
@@ -15,12 +15,12 @@ module Pathway
|
|
15
15
|
self.include plugin::InstanceMethods if plugin.const_defined? :InstanceMethods
|
16
16
|
self::DSL.include plugin::DSLMethods if plugin.const_defined? :DSLMethods
|
17
17
|
|
18
|
-
plugin.apply(self) if plugin.respond_to?(:apply)
|
18
|
+
plugin.apply(self, *args) if plugin.respond_to?(:apply)
|
19
19
|
end
|
20
20
|
|
21
21
|
def self.inherited(subclass)
|
22
|
-
subclass.const_set :DSL, Class.new(self::DSL)
|
23
22
|
super
|
23
|
+
subclass.const_set :DSL, Class.new(self::DSL)
|
24
24
|
end
|
25
25
|
|
26
26
|
class DSL
|
@@ -4,7 +4,8 @@ module Pathway
|
|
4
4
|
module Plugins
|
5
5
|
module DryValidation
|
6
6
|
module ClassMethods
|
7
|
-
attr_reader :form_class
|
7
|
+
attr_reader :form_class, :form_options
|
8
|
+
attr_accessor :auto_wire_options
|
8
9
|
|
9
10
|
def form(base = nil, **opts, &block)
|
10
11
|
if block_given?
|
@@ -20,6 +21,7 @@ module Pathway
|
|
20
21
|
def form_class= klass
|
21
22
|
@builded_form = klass.options.empty? ? klass.new : nil
|
22
23
|
@form_class = klass
|
24
|
+
@form_options = klass.options.keys
|
23
25
|
end
|
24
26
|
|
25
27
|
def build_form(opts = {})
|
@@ -29,6 +31,7 @@ module Pathway
|
|
29
31
|
def inherited(subclass)
|
30
32
|
super
|
31
33
|
subclass.form_class = form_class
|
34
|
+
subclass.auto_wire_options = auto_wire_options
|
32
35
|
end
|
33
36
|
|
34
37
|
private
|
@@ -49,11 +52,14 @@ module Pathway
|
|
49
52
|
module InstanceMethods
|
50
53
|
extend Forwardable
|
51
54
|
|
52
|
-
delegate
|
55
|
+
delegate %i[build_form form_options auto_wire_options] => 'self.class'
|
53
56
|
alias :form :build_form
|
54
57
|
|
55
|
-
def validate(state, with:
|
56
|
-
|
58
|
+
def validate(state, with: nil)
|
59
|
+
if auto_wire_options && form_options.any?
|
60
|
+
with ||= form_options.zip(form_options).to_h
|
61
|
+
end
|
62
|
+
opts = Hash(with).map { |opt, key| [opt, state[key]] }.to_h
|
57
63
|
validate_with(state[:input], opts)
|
58
64
|
.then { |params| state.update(params: params) }
|
59
65
|
end
|
@@ -65,8 +71,9 @@ module Pathway
|
|
65
71
|
end
|
66
72
|
end
|
67
73
|
|
68
|
-
def self.apply(operation)
|
74
|
+
def self.apply(operation, auto_wire_options: false)
|
69
75
|
operation.form_class = Dry::Validation::Schema::Form
|
76
|
+
operation.auto_wire_options = auto_wire_options
|
70
77
|
end
|
71
78
|
end
|
72
79
|
end
|
data/lib/pathway/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pathway
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pablo Herrero
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-08-
|
11
|
+
date: 2017-08-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: inflecto
|