direct 1.1.0 → 1.1.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 +4 -0
- data/lib/direct.rb +32 -0
- data/lib/direct/group.rb +8 -0
- data/lib/direct/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98778b7710dd0641ba88486adc2888551cd823ec4be17494857d42555af8e72a
|
4
|
+
data.tar.gz: b0216ba7745d33ff0f6cf3f1018472d19a8ec3df00b2678bcda68f4074a125d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1fd862dec144d24f9268574cc91a1fae0a9b90052598d2c3f221b5cc23cd383d60966d600db20ba8551751bd11344a2ca8f79b9563cd834dce941569dc08e0cf
|
7
|
+
data.tar.gz: 734e1c4f6095c2c5d7566ba607a438000298e28b1c2d352ba9c93a17ea3e7249956119b69b9e1d6184716006fc158ad5394b03e139c44f5f7f7f0972d549af97
|
data/CHANGELOG.md
CHANGED
data/lib/direct.rb
CHANGED
@@ -7,6 +7,32 @@ require "direct/group"
|
|
7
7
|
module Direct
|
8
8
|
class MissingProcedure < StandardError; end
|
9
9
|
|
10
|
+
module AllowMissing
|
11
|
+
include Direct
|
12
|
+
def allow_missing_directions?
|
13
|
+
true
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# Use this module to allow your procedures to go ignored.
|
18
|
+
#
|
19
|
+
# Example:
|
20
|
+
#
|
21
|
+
# class Thing < ActiveRecord::Base
|
22
|
+
# include Direct.allow_missing_directions
|
23
|
+
#
|
24
|
+
# def save(*)
|
25
|
+
# super
|
26
|
+
# as_directed(:success)
|
27
|
+
# end
|
28
|
+
# end
|
29
|
+
#
|
30
|
+
# Thing.new.save # => no MissingProcedure error raised.
|
31
|
+
#
|
32
|
+
def self.allow_missing_directions
|
33
|
+
AllowMissing
|
34
|
+
end
|
35
|
+
|
10
36
|
# Wrap a block of code to return an object for handling
|
11
37
|
# success or failure.
|
12
38
|
#
|
@@ -57,15 +83,21 @@ module Direct
|
|
57
83
|
#
|
58
84
|
# This will raise an error if the provided key is not found
|
59
85
|
def as_directed(key, *args)
|
86
|
+
return if allow_missing_directions? && __directions.empty?
|
60
87
|
__directions.fetch(key).map do |block|
|
61
88
|
block.call(self, *args)
|
62
89
|
end
|
63
90
|
rescue KeyError
|
91
|
+
return if allow_missing_directions?
|
64
92
|
raise MissingProcedure, "Procedure for :#{key} was reached but not specified."
|
65
93
|
end
|
66
94
|
|
67
95
|
private
|
68
96
|
|
97
|
+
def allow_missing_directions?
|
98
|
+
false
|
99
|
+
end
|
100
|
+
|
69
101
|
def __directions
|
70
102
|
@__directions ||= Direct::Group.new
|
71
103
|
end
|
data/lib/direct/group.rb
CHANGED
data/lib/direct/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: direct
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jim Gay
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-02-
|
11
|
+
date: 2019-02-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
@@ -93,7 +93,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
93
93
|
- !ruby/object:Gem::Version
|
94
94
|
version: '0'
|
95
95
|
requirements: []
|
96
|
-
|
96
|
+
rubyforge_project:
|
97
|
+
rubygems_version: 2.7.6
|
97
98
|
signing_key:
|
98
99
|
specification_version: 4
|
99
100
|
summary: Direct objects to perform arbitrary blocks by name
|