Class: Object
- Inherits:
- BasicObject
- Defined in:
- lib/aspectory.rb
Instance Method Summary collapse
- #meta_def(name, &block) ⇒ Object
- #meta_eval(&block) ⇒ Object
- #metaclass ⇒ Object
- #tap ⇒ Object
- #try(sym, *args, &block) ⇒ Object
Instance Method Details
#meta_def(name, &block) ⇒ Object
47 48 49 |
# File 'lib/aspectory.rb', line 47 def (name, &block) { define_method(name, &block) } end |
#meta_eval(&block) ⇒ Object
43 44 45 |
# File 'lib/aspectory.rb', line 43 def (&block) .instance_eval(&block) end |
#metaclass ⇒ Object
39 40 41 |
# File 'lib/aspectory.rb', line 39 def class << self; self end end |
#tap ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/aspectory.rb', line 19 def tap if block_given? yield self self else Class.new { instance_methods.each { |m| undef_method(m) unless m.to_s =~ /__/ } def initialize(target) @target = target end def method_missing(sym, *args, &block) @target.send(sym, *args, &block) @target end }.new(self) end end |
#try(sym, *args, &block) ⇒ Object
15 16 17 |
# File 'lib/aspectory.rb', line 15 def try(sym, *args, &block) respond_to?(sym) ? send(sym, *args, &block) : nil end |