subroutine 0.5.1 → 0.5.2
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/subroutine/op.rb +11 -4
- data/lib/subroutine/version.rb +1 -1
- data/test/subroutine/base_test.rb +14 -0
- data/test/support/ops.rb +8 -0
- 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: a1bc6198e47ce610c393d061ea8d657d9fbaed30
|
4
|
+
data.tar.gz: d51c78f5328d91119eb2ec1c252383645d8e9485
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 265862ad55b33f9c16ab8665666d870480d7297c095dcd9a387e86d8c4a7ff81b512cae2a2cfbaea57eda3ffff134c4a943b6bf1835a2508a59be11661fd4e0c
|
7
|
+
data.tar.gz: e4b8325a9f266f14bf1915ca05080e74d3e7361a759433997e4f4d602df8ed5a63707933e0e636b741868bbd9d1443cfea004a1080176faf4f5ca69b4883a40e
|
data/lib/subroutine/op.rb
CHANGED
@@ -72,13 +72,20 @@ module Subroutine
|
|
72
72
|
alias_method :ignore_errors, :ignore_error
|
73
73
|
|
74
74
|
def inputs_from(*ops)
|
75
|
+
options = ops.extract_options!
|
76
|
+
excepts = options.key?(:except) ? Array(options.delete(:except)) : nil
|
77
|
+
onlys = options.key?(:only) ? Array(options.delete(:only)) : nil
|
78
|
+
|
75
79
|
ops.each do |op|
|
76
|
-
op._fields.each_pair do |field_name,
|
77
|
-
if
|
80
|
+
op._fields.each_pair do |field_name, op_options|
|
81
|
+
next if excepts && excepts.include?(field_name)
|
82
|
+
next if onlys && !onlys.include?(field_name)
|
83
|
+
|
84
|
+
if op_options[:association]
|
78
85
|
include ::Subroutine::Association unless included_modules.include?(::Subroutine::Association)
|
79
|
-
association(field_name,
|
86
|
+
association(field_name, op_options)
|
80
87
|
else
|
81
|
-
field(field_name,
|
88
|
+
field(field_name, op_options)
|
82
89
|
end
|
83
90
|
end
|
84
91
|
end
|
data/lib/subroutine/version.rb
CHANGED
@@ -33,6 +33,20 @@ module Subroutine
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
+
def test_inputs_from_ignores_except_fields
|
37
|
+
op = ::ExceptFooBarOp.new
|
38
|
+
refute op._fields.keys.include? :foo
|
39
|
+
refute op._fields.keys.include? :bar
|
40
|
+
assert_equal [:baz], op._fields.keys.sort
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_inputs_from_only_fields
|
44
|
+
op = ::OnlyFooBarOp.new
|
45
|
+
assert op._fields.keys.include? :foo
|
46
|
+
assert op._fields.keys.include? :bar
|
47
|
+
refute_equal [:baz], op._fields.keys.sort
|
48
|
+
end
|
49
|
+
|
36
50
|
def test_defaults_declaration_options
|
37
51
|
op = ::DefaultsOp.new
|
38
52
|
assert_equal 'foo', op.foo
|
data/test/support/ops.rb
CHANGED
@@ -92,6 +92,14 @@ class DefaultsOp < ::Subroutine::Op
|
|
92
92
|
|
93
93
|
end
|
94
94
|
|
95
|
+
class ExceptFooBarOp < ::Subroutine::Op
|
96
|
+
inputs_from ::DefaultsOp, except: %i[foo bar]
|
97
|
+
end
|
98
|
+
|
99
|
+
class OnlyFooBarOp < ::Subroutine::Op
|
100
|
+
inputs_from ::DefaultsOp, only: %i[foo bar]
|
101
|
+
end
|
102
|
+
|
95
103
|
class InheritedDefaultsOp < ::DefaultsOp
|
96
104
|
|
97
105
|
field :bar, :default => 'barstool'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: subroutine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Nelson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-10-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|