Module: CoAspects::Callbacks

Defined in:
lib/co_aspects/callbacks.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &block) ⇒ Object



8
9
10
11
12
13
# File 'lib/co_aspects/callbacks.rb', line 8

def method_missing(method_name, *args, &block)
  return super unless /\A_/ =~ method_name
  args.each { |arg| fail InvalidArgument.new(arg) unless arg.kind_of?(Hash) }
  options = Hash[*args.map(&:to_a).flatten]
  (@__aspects_attacher__ ||= Attacher.new).add(method_name, options, block)
end

Instance Method Details

#method_added(method_name) ⇒ Object



3
4
5
6
# File 'lib/co_aspects/callbacks.rb', line 3

def method_added(method_name)
  super
  (@__aspects_attacher__ ||= Attacher.new).attach(self, method_name)
end