smack 1.0.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +11 -1
- data/VERSION +1 -1
- data/lib/smack.rb +1 -4
- data/smack.gemspec +1 -1
- data/test/smack_test.rb +1 -1
- metadata +1 -1
data/README.rdoc
CHANGED
@@ -5,12 +5,22 @@ Hi. This is dependency injection for the rest of us. See smack_test.rb for examp
|
|
5
5
|
== FAQ
|
6
6
|
|
7
7
|
Q: COOL IS THIS LIKE ONE OF THOSE JAVA DI FRAMEWORKS?
|
8
|
-
|
8
|
+
|
9
|
+
A: No. This is an entire 12 lines of dumb code.
|
10
|
+
|
9
11
|
|
10
12
|
Q: WHY ARE YOU DOING DI IN RUBY ARE YOU A MANIAC?
|
13
|
+
|
11
14
|
A: DI is a fine pattern and is sometimes necessary. It's just simpler to do in Ruby, hence the 15 lines of code. This just gives you nice syntax for it.
|
15
|
+
|
16
|
+
|
17
|
+
Q: SHOULD I USE THIS IN PRODUCTION CODE?
|
18
|
+
|
19
|
+
A: It's mostly a joke so probably not.
|
20
|
+
|
12
21
|
|
13
22
|
Q: WHY ARE ALL YOUR PROJECT NAMES SO TERRIBLE?
|
23
|
+
|
14
24
|
A: Marketing isn't really my strong point.
|
15
25
|
|
16
26
|
== Copyright
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
2.0.0
|
data/lib/smack.rb
CHANGED
@@ -1,14 +1,11 @@
|
|
1
1
|
module Smack
|
2
|
-
def self.
|
3
|
-
|
2
|
+
def self.up; Object.instance_eval { include Smack }; end
|
4
3
|
def smack_inject(substitutions)
|
5
4
|
(class << self; self; end).instance_eval { @smack_subs = (@smack_subs || {}).merge!(substitutions) }
|
6
5
|
end
|
7
|
-
|
8
6
|
def smack_get(klass_or_mod)
|
9
7
|
[self, *(class << self; self; end).ancestors].any? { |mod| (found_mod = mod.smack_fetch(klass_or_mod)) ? (break(found_mod)) : nil } || klass_or_mod
|
10
8
|
end
|
11
|
-
|
12
9
|
def smack_fetch(klass_or_mod)
|
13
10
|
(class << self; self; end).instance_eval { @smack_subs ? @smack_subs[klass_or_mod] : nil }
|
14
11
|
end
|
data/smack.gemspec
CHANGED
data/test/smack_test.rb
CHANGED