coiasira 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/coiasira/rails/initializer.rb +26 -41
- data/lib/coiasira/version.rb +1 -1
- metadata +3 -3
@@ -1,25 +1,29 @@
|
|
1
|
-
module
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
yield(aliased_target, punctuation) if block_given?
|
1
|
+
module Coiasira::AliasMethodChainCoreExt
|
2
|
+
def alias_method_chain(target, feature)
|
3
|
+
# Strip out punctuation on predicates or bang methods since
|
4
|
+
# e.g. target?_without_feature is not a valid method name.
|
5
|
+
aliased_target, punctuation = target.to_s.sub(/([?!=])$/, ''), $1
|
6
|
+
yield(aliased_target, punctuation) if block_given?
|
8
7
|
|
9
|
-
|
8
|
+
with_method, without_method = "#{aliased_target}_with_#{feature}#{punctuation}", "#{aliased_target}_without_#{feature}#{punctuation}"
|
10
9
|
|
11
|
-
|
12
|
-
|
10
|
+
alias_method without_method, target
|
11
|
+
alias_method target, with_method
|
13
12
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
end
|
13
|
+
case
|
14
|
+
when public_method_defined?(without_method)
|
15
|
+
public target
|
16
|
+
when protected_method_defined?(without_method)
|
17
|
+
protected target
|
18
|
+
when private_method_defined?(without_method)
|
19
|
+
private target
|
22
20
|
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
module Rails
|
25
|
+
class Initializer
|
26
|
+
extend Coiasira::AliasMethodChainCoreExt
|
23
27
|
|
24
28
|
def initialize_coiasira
|
25
29
|
return unless configuration.frameworks.include?(:coiasira)
|
@@ -36,26 +40,7 @@ module Rails
|
|
36
40
|
end
|
37
41
|
|
38
42
|
class Configuration
|
39
|
-
|
40
|
-
# Strip out punctuation on predicates or bang methods since
|
41
|
-
# e.g. target?_without_feature is not a valid method name.
|
42
|
-
aliased_target, punctuation = target.to_s.sub(/([?!=])$/, ''), $1
|
43
|
-
yield(aliased_target, punctuation) if block_given?
|
44
|
-
|
45
|
-
with_method, without_method = "#{aliased_target}_with_#{feature}#{punctuation}", "#{aliased_target}_without_#{feature}#{punctuation}"
|
46
|
-
|
47
|
-
alias_method without_method, target
|
48
|
-
alias_method target, with_method
|
49
|
-
|
50
|
-
case
|
51
|
-
when public_method_defined?(without_method)
|
52
|
-
public target
|
53
|
-
when protected_method_defined?(without_method)
|
54
|
-
protected target
|
55
|
-
when private_method_defined?(without_method)
|
56
|
-
private target
|
57
|
-
end
|
58
|
-
end
|
43
|
+
extend Coiasira::AliasMethodChainCoreExt
|
59
44
|
|
60
45
|
attr_accessor :coiasira
|
61
46
|
|
@@ -75,13 +60,13 @@ module Rails
|
|
75
60
|
end
|
76
61
|
alias_method_chain :default_frameworks, :coiasira
|
77
62
|
|
78
|
-
def
|
79
|
-
paths =
|
63
|
+
def default_autoload_paths_with_coiasira
|
64
|
+
paths = default_autoload_paths_without_coiasira
|
80
65
|
|
81
66
|
# Add the app's job directory
|
82
67
|
paths.concat(Dir["#{root_path}/app/jobs/"])
|
83
68
|
end
|
84
|
-
alias_method_chain :
|
69
|
+
alias_method_chain :default_autoload_paths, :coiasira
|
85
70
|
|
86
71
|
def default_job_paths
|
87
72
|
[File.join(root_path, 'app', 'jobs')]
|
data/lib/coiasira/version.rb
CHANGED
metadata
CHANGED