Sha256: 6320ab898a90d0142cc572b900fafda182304ad05978a196e3cad256c14dd9bc

Contents?: true

Size: 838 Bytes

Versions: 14

Compression:

Stored size: 838 Bytes

Contents

require 'ostruct'


module Xot


  module Invoker

    def initialize()
    end

    def handlers(create = false)
      if create
        @handlers ||= []
      else
        @handlers ? @handlers : []
      end
    end

    def add_handler(handler)
      return unless handler
      a = self.handlers true
      a.push handler unless a.include? handler
    end

    def remove_handler(handler)
      return unless handler
      self.handlers.delete handler
    end

    def invoke(name, attributes = {}, options = {})
      only     = options[:only]
      only     = [only] if only && !only.kind_of?(Array)
      handlers = only ? only : @handlers
      return unless handlers

      handlers.each do |handler|
        handler.send name, OpenStruct.new(attributes) if handler.respond_to? name
      end
    end

  end# Invoker


end# Xot

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
xot-0.3.3 lib/xot/invoker.rb
xot-0.3.2 lib/xot/invoker.rb
xot-0.3.1 lib/xot/invoker.rb
xot-0.3 lib/xot/invoker.rb
xot-0.2.1 lib/xot/invoker.rb
xot-0.2 lib/xot/invoker.rb
xot-0.1.42 lib/xot/invoker.rb
xot-0.1.41 lib/xot/invoker.rb
xot-0.1.40 lib/xot/invoker.rb
xot-0.1.39 lib/xot/invoker.rb
xot-0.1.38 lib/xot/invoker.rb
xot-0.1.37 lib/xot/invoker.rb
xot-0.1.36 lib/xot/invoker.rb
xot-0.1.35 lib/xot/invoker.rb