active_interaction 1.5.0 → 1.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -2
- data/CONTRIBUTING.md +19 -0
- data/README.md +1109 -183
- data/lib/active_interaction.rb +1 -1
- data/lib/active_interaction/backports.rb +2 -3
- data/lib/active_interaction/base.rb +1 -1
- data/lib/active_interaction/concerns/active_recordable.rb +1 -2
- data/lib/active_interaction/concerns/transactable.rb +3 -3
- data/lib/active_interaction/errors.rb +1 -1
- data/lib/active_interaction/filters/array_filter.rb +4 -4
- data/lib/active_interaction/filters/model_filter.rb +1 -1
- data/lib/active_interaction/version.rb +1 -1
- data/spec/active_interaction/concerns/active_recordable_spec.rb +2 -2
- data/spec/active_interaction/errors_spec.rb +1 -2
- data/spec/active_interaction/i18n_spec.rb +1 -2
- data/spec/active_interaction/integration/interface_interaction_spec.rb +10 -1
- data/spec/active_interaction/integration/model_interaction_spec.rb +10 -1
- metadata +24 -21
data/lib/active_interaction.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
# rubocop:disable Documentation
|
4
3
|
module ActiveInteraction
|
5
|
-
class GroupedInput
|
4
|
+
class GroupedInput # rubocop:disable Style/Documentation
|
6
5
|
# Required for Ruby <= 1.9.3.
|
7
6
|
def [](name)
|
8
7
|
send(name)
|
@@ -14,7 +13,7 @@ module ActiveInteraction
|
|
14
13
|
end unless method_defined?(:[]=)
|
15
14
|
end
|
16
15
|
|
17
|
-
class Errors
|
16
|
+
class Errors # rubocop:disable Style/Documentation
|
18
17
|
# Required for Rails < 3.2.13.
|
19
18
|
protected :initialize_dup
|
20
19
|
end
|
@@ -240,7 +240,7 @@ module ActiveInteraction
|
|
240
240
|
self.class.filters.each do |name, filter|
|
241
241
|
begin
|
242
242
|
public_send("#{name}=", filter.clean(inputs[name]))
|
243
|
-
rescue
|
243
|
+
rescue Error
|
244
244
|
# #type_check will add errors if appropriate.
|
245
245
|
end
|
246
246
|
end
|
@@ -50,9 +50,8 @@ module ActiveInteraction
|
|
50
50
|
# @return [Boolean]
|
51
51
|
#
|
52
52
|
# @since 1.5.0
|
53
|
-
def has_attribute?(name) # rubocop:disable PredicateName
|
53
|
+
def has_attribute?(name) # rubocop:disable Style/PredicateName
|
54
54
|
self.class.filters.key?(name.to_sym)
|
55
55
|
end
|
56
|
-
# rubocop:enable PredicateName
|
57
56
|
end
|
58
57
|
end
|
@@ -3,10 +3,10 @@
|
|
3
3
|
begin
|
4
4
|
require 'active_record'
|
5
5
|
rescue LoadError
|
6
|
-
module ActiveRecord # rubocop:disable Documentation
|
6
|
+
module ActiveRecord # rubocop:disable Style/Documentation
|
7
7
|
Rollback = Class.new(ActiveInteraction::Error)
|
8
8
|
|
9
|
-
class Base # rubocop:disable Documentation
|
9
|
+
class Base # rubocop:disable Style/Documentation
|
10
10
|
def self.transaction(*)
|
11
11
|
yield
|
12
12
|
rescue Rollback
|
@@ -38,7 +38,7 @@ module ActiveInteraction
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
-
module ClassMethods # rubocop:disable Documentation
|
41
|
+
module ClassMethods # rubocop:disable Style/Documentation
|
42
42
|
# @param klass [Class]
|
43
43
|
def inherited(klass)
|
44
44
|
klass.transaction(transaction?, transaction_options.dup)
|
@@ -48,7 +48,7 @@ module ActiveInteraction
|
|
48
48
|
super do |klass, names, options|
|
49
49
|
filter = klass.new(name.to_s.singularize.to_sym, options, &block)
|
50
50
|
|
51
|
-
validate(filter, names)
|
51
|
+
validate!(filter, names)
|
52
52
|
|
53
53
|
filters[filter.name] = filter
|
54
54
|
end
|
@@ -71,7 +71,7 @@ module ActiveInteraction
|
|
71
71
|
# @param names [Array<Symbol>]
|
72
72
|
#
|
73
73
|
# @raise [InvalidFilterError]
|
74
|
-
def validate(filter, names)
|
74
|
+
def validate!(filter, names)
|
75
75
|
unless filters.empty?
|
76
76
|
fail InvalidFilterError, 'multiple filters in array block'
|
77
77
|
end
|
@@ -80,11 +80,11 @@ module ActiveInteraction
|
|
80
80
|
fail InvalidFilterError, 'attribute names in array block'
|
81
81
|
end
|
82
82
|
|
83
|
-
# rubocop:disable GuardClause
|
84
83
|
if filter.default?
|
85
84
|
fail InvalidDefaultError, 'default values in array block'
|
86
85
|
end
|
87
|
-
|
86
|
+
|
87
|
+
nil
|
88
88
|
end
|
89
89
|
end
|
90
90
|
end
|
@@ -2,14 +2,14 @@
|
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
|
-
|
5
|
+
InteractionWithFloatFilter = Class.new(TestInteraction) do
|
6
6
|
float :thing
|
7
7
|
end
|
8
8
|
|
9
9
|
describe ActiveInteraction::ActiveRecordable do
|
10
10
|
include_context 'interactions'
|
11
11
|
|
12
|
-
let(:described_class) {
|
12
|
+
let(:described_class) { InteractionWithFloatFilter }
|
13
13
|
|
14
14
|
describe '#column_for_attribute(name)' do
|
15
15
|
let(:column) { outcome.column_for_attribute(name) }
|
@@ -4,9 +4,18 @@ require 'spec_helper'
|
|
4
4
|
require 'json'
|
5
5
|
require 'yaml'
|
6
6
|
|
7
|
-
|
7
|
+
InterfaceInteraction = Class.new(TestInteraction) do
|
8
|
+
interface :anything
|
9
|
+
end
|
10
|
+
|
11
|
+
describe InterfaceInteraction do
|
12
|
+
include_context 'interactions'
|
8
13
|
it_behaves_like 'an interaction',
|
9
14
|
:interface,
|
10
15
|
-> { [JSON, YAML].sample },
|
11
16
|
methods: [:dump, :load]
|
17
|
+
|
18
|
+
it 'succeeds when given nil' do
|
19
|
+
expect { result }.to_not raise_error
|
20
|
+
end
|
12
21
|
end
|
@@ -2,6 +2,15 @@
|
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
|
-
|
5
|
+
ModelInteraction = Class.new(TestInteraction) do
|
6
|
+
model :object
|
7
|
+
end
|
8
|
+
|
9
|
+
describe ModelInteraction do
|
10
|
+
include_context 'interactions'
|
6
11
|
it_behaves_like 'an interaction', :model, -> { // }, class: Regexp
|
12
|
+
|
13
|
+
it 'succeeds when given nil' do
|
14
|
+
expect { result }.to_not raise_error
|
15
|
+
end
|
7
16
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_interaction
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Lasseigne
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-04-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activemodel
|
@@ -37,112 +37,112 @@ dependencies:
|
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '1.
|
40
|
+
version: '1.9'
|
41
41
|
type: :development
|
42
42
|
prerelease: false
|
43
43
|
version_requirements: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '1.
|
47
|
+
version: '1.9'
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: coveralls
|
50
50
|
requirement: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '0.
|
54
|
+
version: '0.8'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
57
|
version_requirements: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0.
|
61
|
+
version: '0.8'
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
63
|
name: guard-rspec
|
64
64
|
requirement: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '4.
|
68
|
+
version: '4.5'
|
69
69
|
type: :development
|
70
70
|
prerelease: false
|
71
71
|
version_requirements: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '4.
|
75
|
+
version: '4.5'
|
76
76
|
- !ruby/object:Gem::Dependency
|
77
77
|
name: guard-rubocop
|
78
78
|
requirement: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '1.
|
82
|
+
version: '1.2'
|
83
83
|
type: :development
|
84
84
|
prerelease: false
|
85
85
|
version_requirements: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '1.
|
89
|
+
version: '1.2'
|
90
90
|
- !ruby/object:Gem::Dependency
|
91
91
|
name: kramdown
|
92
92
|
requirement: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '1.
|
96
|
+
version: '1.7'
|
97
97
|
type: :development
|
98
98
|
prerelease: false
|
99
99
|
version_requirements: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '1.
|
103
|
+
version: '1.7'
|
104
104
|
- !ruby/object:Gem::Dependency
|
105
105
|
name: rake
|
106
106
|
requirement: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '10.
|
110
|
+
version: '10.4'
|
111
111
|
type: :development
|
112
112
|
prerelease: false
|
113
113
|
version_requirements: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: '10.
|
117
|
+
version: '10.4'
|
118
118
|
- !ruby/object:Gem::Dependency
|
119
119
|
name: rspec
|
120
120
|
requirement: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: '3.
|
124
|
+
version: '3.2'
|
125
125
|
type: :development
|
126
126
|
prerelease: false
|
127
127
|
version_requirements: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
129
|
- - "~>"
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version: '3.
|
131
|
+
version: '3.2'
|
132
132
|
- !ruby/object:Gem::Dependency
|
133
133
|
name: rubocop
|
134
134
|
requirement: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version: '0.
|
138
|
+
version: '0.30'
|
139
139
|
type: :development
|
140
140
|
prerelease: false
|
141
141
|
version_requirements: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
143
|
- - "~>"
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
version: '0.
|
145
|
+
version: '0.30'
|
146
146
|
- !ruby/object:Gem::Dependency
|
147
147
|
name: yard
|
148
148
|
requirement: !ruby/object:Gem::Requirement
|
@@ -157,7 +157,9 @@ dependencies:
|
|
157
157
|
- - "~>"
|
158
158
|
- !ruby/object:Gem::Version
|
159
159
|
version: '0.8'
|
160
|
-
description:
|
160
|
+
description: |2
|
161
|
+
ActiveInteraction manages application-specific business logic. It is an
|
162
|
+
implementation of the command pattern in Ruby.
|
161
163
|
email:
|
162
164
|
- aaron.lasseigne@gmail.com
|
163
165
|
- taylor@fausak.me
|
@@ -166,6 +168,7 @@ extensions: []
|
|
166
168
|
extra_rdoc_files: []
|
167
169
|
files:
|
168
170
|
- CHANGELOG.md
|
171
|
+
- CONTRIBUTING.md
|
169
172
|
- LICENSE.txt
|
170
173
|
- README.md
|
171
174
|
- lib/active_interaction.rb
|
@@ -250,7 +253,7 @@ files:
|
|
250
253
|
- spec/support/concerns.rb
|
251
254
|
- spec/support/filters.rb
|
252
255
|
- spec/support/interactions.rb
|
253
|
-
homepage: http://orgsync.
|
256
|
+
homepage: http://devblog.orgsync.com/active_interaction/
|
254
257
|
licenses:
|
255
258
|
- MIT
|
256
259
|
metadata: {}
|
@@ -270,7 +273,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
270
273
|
version: '0'
|
271
274
|
requirements: []
|
272
275
|
rubyforge_project:
|
273
|
-
rubygems_version: 2.4.
|
276
|
+
rubygems_version: 2.4.6
|
274
277
|
signing_key:
|
275
278
|
specification_version: 4
|
276
279
|
summary: Manage application specific business logic.
|