Method: ClassX::Pluggable#call_event_around

Defined in:
lib/classx/pluggable.rb

#call_event_around(name, *args, &block) ⇒ Object

invoke registered event of BEFORE_xxxx and yield block and invoke hook AFTER_xxxx.



129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/classx/pluggable.rb', line 129

def call_event_around name, *args, &block
  name = name.to_s
  around_name = "AROUND_#{name}"

  call_event("BEFORE_#{name}", *args)
  if events = self.__classx_pluggable_events_of[around_name]
    procs = []
    procs << block
    index = 0
    nested_proc = events.inject(block) {|bl, event| proc { event[:plugin].__send__(event[:method], *args, &bl ) } }
    nested_proc.call
  end
  call_event("AFTER_#{name}", *args)
end