Sha256: 2dd191436c43ebdcf214d808f83a3b9394417b54453ebf0f972e749d2eb737da

Contents?: true

Size: 387 Bytes

Versions: 3

Compression:

Stored size: 387 Bytes

Contents

module Elevate
  class Callback
    def initialize(controller, block)
      @controller = controller
      @block = block
    end

    def call(*args)
      if NSThread.isMainThread
        invoke(*args)
      else
        Dispatch::Queue.main.sync { invoke(*args) }
      end
    end

    private

    def invoke(*args)
      @controller.instance_exec(*args, &@block)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
elevate-0.6.0 lib/elevate/callback.rb
elevate-0.5.0 lib/elevate/callback.rb
elevate-0.4.0 lib/elevate/callback.rb