Sha256: 50c58ea871dd4418943badd78f2bc63a6b5bfc9052a99c5fbde3a86fbf7db65d

Contents?: true

Size: 864 Bytes

Versions: 13

Compression:

Stored size: 864 Bytes

Contents

# -*- coding: utf-8 -*-


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

13 entries across 13 versions & 1 rubygems

Version Path
xot-0.1.34 lib/xot/invoker.rb
xot-0.1.33 lib/xot/invoker.rb
xot-0.1.32 lib/xot/invoker.rb
xot-0.1.31 lib/xot/invoker.rb
xot-0.1.30 lib/xot/invoker.rb
xot-0.1.29 lib/xot/invoker.rb
xot-0.1.28 lib/xot/invoker.rb
xot-0.1.27 lib/xot/invoker.rb
xot-0.1.26 lib/xot/invoker.rb
xot-0.1.25 lib/xot/invoker.rb
xot-0.1.24 lib/xot/invoker.rb
xot-0.1.23 lib/xot/invoker.rb
xot-0.1.22 lib/xot/invoker.rb