verbalize 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/.rubocop.yml +1 -1
- data/lib/verbalize/build_dangerous_action_method.rb +5 -7
- data/lib/verbalize/build_safe_action_method.rb +5 -9
- data/lib/verbalize/version.rb +1 -1
- data/lib/verbalize.rb +22 -10
- 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: 61174d8fa1734e70a63a74b34060d056515098ca
|
4
|
+
data.tar.gz: b3fc22d20687f9eba615606cdbc10865e56ea02f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3aeff77f6ce6012c78c597cfaadd60f19450e0cdfbd2c08e9f785b2a32b60d55685cc5571c97f0278a8c35795548811ade2e1dcc20209fe8bf7f9a600c5fbd5
|
7
|
+
data.tar.gz: f5c66899c7b5bcf67b088b92cbdeb1e81191d6479cea19204b9d8541cd144eec97a7f3b33e35a83ff67762429d703f05d896c8b3428e5ef679620de530eb69ab
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -9,13 +9,11 @@ module Verbalize
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def body
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
raise error
|
18
|
-
BODY
|
12
|
+
if all_keywords.empty?
|
13
|
+
" __verbalized_send!(:#{method_name})"
|
14
|
+
else
|
15
|
+
" __verbalized_send!(:#{method_name}, #{initialize_keywords_and_values})"
|
16
|
+
end
|
19
17
|
end
|
20
18
|
end
|
21
19
|
end
|
@@ -9,15 +9,11 @@ module Verbalize
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def body
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
else
|
18
|
-
Result.new(outcome: :ok, value: result)
|
19
|
-
end
|
20
|
-
BODY
|
12
|
+
if all_keywords.empty?
|
13
|
+
" __verbalized_send(:#{method_name})"
|
14
|
+
else
|
15
|
+
" __verbalized_send(:#{method_name}, #{initialize_keywords_and_values})"
|
16
|
+
end
|
21
17
|
end
|
22
18
|
end
|
23
19
|
end
|
data/lib/verbalize/version.rb
CHANGED
data/lib/verbalize.rb
CHANGED
@@ -6,10 +6,11 @@ require 'verbalize/build_attribute_readers'
|
|
6
6
|
require 'verbalize/result'
|
7
7
|
|
8
8
|
module Verbalize
|
9
|
+
THROWN_SYMBOL = :verbalize_error
|
9
10
|
VerbalizeError = Class.new(StandardError)
|
10
11
|
|
11
12
|
def fail!(failure_value = nil)
|
12
|
-
throw(
|
13
|
+
throw(THROWN_SYMBOL, failure_value)
|
13
14
|
end
|
14
15
|
|
15
16
|
def self.included(target)
|
@@ -61,19 +62,30 @@ module Verbalize
|
|
61
62
|
end
|
62
63
|
|
63
64
|
def call
|
64
|
-
|
65
|
-
result = catch(:verbalize_error) { action.send(:call) }
|
66
|
-
if result.is_a?(Result)
|
67
|
-
result
|
68
|
-
else
|
69
|
-
Result.new(outcome: :ok, value: result)
|
70
|
-
end
|
65
|
+
__verbalized_send(:call)
|
71
66
|
end
|
72
67
|
|
73
68
|
def call!
|
74
|
-
|
69
|
+
__verbalized_send!(:call)
|
70
|
+
end
|
71
|
+
|
72
|
+
private
|
73
|
+
|
74
|
+
def __verbalized_send(method_name, *args)
|
75
|
+
outcome = :error
|
76
|
+
value = catch(:verbalize_error) do
|
77
|
+
value = new(*args).send(method_name)
|
78
|
+
# The outcome is :ok if the call didn't throw.
|
79
|
+
outcome = :ok
|
80
|
+
value
|
81
|
+
end
|
82
|
+
Result.new(outcome: outcome, value: value)
|
83
|
+
end
|
84
|
+
|
85
|
+
def __verbalized_send!(method_name, *args)
|
86
|
+
new(*args).send(method_name)
|
75
87
|
rescue UncaughtThrowError => uncaught_throw_error
|
76
|
-
fail_value = uncaught_throw_error.value
|
88
|
+
fail_value = uncaught_throw_error.value
|
77
89
|
error = VerbalizeError.new("Unhandled fail! called with: #{fail_value.inspect}.")
|
78
90
|
error.set_backtrace(uncaught_throw_error.backtrace[2..-1])
|
79
91
|
raise error
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: verbalize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zach Taylor
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-11-
|
11
|
+
date: 2016-11-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|