module Magic::Listener

Public Class Methods

included(base) click to toggle source
# File lib/extmodules/magic.rb, line 108
def self.included(base)
  base.class_eval do

    alias_method :mod_listener, :prepare_config

    define_method :prepare_config do
      mod_listener rescue "skip"
      call = @config[:call]
      if call.is_a? Array
        if call.first.is_a? Array 
          call.each do |c|
            call_on = call[0]
            call_fn = call[1]
          end
        else
          call_on = call[0]
          call_fn = call[1]
        end
      else
        call = []
        { 
          :call_on => @default_config[:call_on],
          :call_fn => @config[:call]
        }
        call << [@default_config[:call_on], @config[:call]]
      end

      @default_config.merge! :emptyText => "Select #{text}" unless text.nil?
    end

  end
end