Public Instance methods
callbacks_for?(type)
[show source]
# File lib/httpx/callbacks.rb 22 def callbacks_for?(type) 23 @callbacks.key?(type) && @callbacks[type].any? 24 end
emit(type, *args)
[show source]
# File lib/httpx/callbacks.rb 18 def emit(type, *args) 19 callbacks(type).delete_if { |pr| :delete == pr.call(*args) } # rubocop:disable Style/YodaCondition 20 end
on(type, &action)
[show source]
# File lib/httpx/callbacks.rb 5 def on(type, &action) 6 callbacks(type) << action 7 self 8 end
once(type, &block)
[show source]
# File lib/httpx/callbacks.rb 10 def once(type, &block) 11 on(type) do |*args, &callback| 12 block.call(*args, &callback) 13 :delete 14 end 15 self 16 end
Protected Instance methods
callbacks(type = nil)
[show source]
# File lib/httpx/callbacks.rb 28 def callbacks(type = nil) 29 return @callbacks unless type 30 31 @callbacks ||= Hash.new { |h, k| h[k] = [] } 32 @callbacks[type] 33 end