Module: Smack
- Defined in:
- lib/smack.rb
Class Method Summary collapse
Instance Method Summary collapse
- #smack_fetch(klass_or_mod) ⇒ Object
- #smack_inject(substitutions) ⇒ Object
- #smack_score(klass_or_mod) ⇒ Object
Class Method Details
.up ⇒ Object
2 |
# File 'lib/smack.rb', line 2 def self.up; Object.instance_eval { include Smack }; end |
Instance Method Details
#smack_fetch(klass_or_mod) ⇒ Object
9 10 11 |
# File 'lib/smack.rb', line 9 def smack_fetch(klass_or_mod) (class << self; self; end).instance_eval { @smack_subs ? @smack_subs[klass_or_mod] : nil } end |
#smack_inject(substitutions) ⇒ Object
3 4 5 |
# File 'lib/smack.rb', line 3 def smack_inject(substitutions) (class << self; self; end).instance_eval { @smack_subs = (@smack_subs || {}).merge!(substitutions) } end |
#smack_score(klass_or_mod) ⇒ Object
6 7 8 |
# File 'lib/smack.rb', line 6 def smack_score(klass_or_mod) [self, *(class << self; self; end).ancestors].any? { |mod| (found_mod = mod.smack_fetch(klass_or_mod)) ? (break(found_mod)) : nil } || klass_or_mod end |