Sha256: ced8be22aedb33e423a7dce09f0dcfe96d48a2ce057b81f5251fe9ff70b30436

Contents?: true

Size: 617 Bytes

Versions: 3

Compression:

Stored size: 617 Bytes

Contents

# Represents a single callback. Contains knowledge of the callback name and object
# and contains a method for calling the callback.

module Flirt

    class Callback

        attr_accessor :object, :callback_name

        def initialize(opts = {})
            self.callback_name = opts.fetch(:callback_name)
            self.object        = opts.fetch(:object)
        end


        def call(event_data)
            object.send callback_name, event_data
        end


        def ==(other_callback)
            object == other_callback.object && callback_name == other_callback.callback_name
        end

    end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
flirt-0.1.1 lib/flirt/callback.rb
flirt-0.1.0 lib/flirt/callback.rb
flirt-0.0.4 lib/flirt/callback.rb