lib/rails/graphql/event.rb
# Fetch all the events from the object, get only the ones that are from
# the same name as the instance of this class and call +trigger+. It runs
# in reverse order, so first in first out. Since events can sometimes be
# cached, using +events+ avoid calculating the +all_events+
Fetch all the events from the object, get only the ones that are from
the same name as the instance of this class and call +trigger+. It runs
in reverse order, so first in first out. Since events can sometimes be
cached, using +events+ avoid calculating the +all_events+
Fetch all the events from the object get only the ones that are from the same name as the instance of this class and call + trigger + . It runs in reverse order so first in first out . Since events can sometimes be cached using + events + avoid calculating the + all_events +
def trigger_object(object, events = nil)
        @items ||= nil
        @object ||= nil
        @last_result ||= nil
        old_items, old_object, old_result, @object = @items, @object, @last_result, object
        catchable(:object) do
          events ||= object.all_events[name]
          stop if events.blank?
          @items = @reverse ? events.reverse_each : events.each
          call_next while @items.peek
        rescue StopIteration
          return @last_result
        end
      ensure
        @items = old_items
        @object = old_object
        @last_result = old_result
      end
def trigger_object ( object , events = nil ) @items ||= nil @object ||= nil @last_result ||= nil old_items , old_object , old_result , @object = @items , @object , @last_result , object catchable ( :object ) do events ||= object . all_events [ name ] stop if events . blank? @items = @reverse ? events . reverse_each : events . each call_next while @items . peek rescue StopIteration return @last_result end ensure @items = old_items @object = old_object @last_result = old_result end
Fetch all the events from the object, get only the ones that are from
the same name as the instance of this class and call +trigger+.
Fetch all the events from the object get only the ones that are from the same name as the instance of this class and call + trigger + .
# TODO: Make sure that the +@collect+ works
object
events