Sha256: ed85e2358962ad97d35d961798e2bb06f305bec8dca26e23f302085d7480a3a4
Contents?: true
Size: 1.46 KB
Versions: 6
Compression:
Stored size: 1.46 KB
Contents
module Smoke module Source # :nodoc: # The "Joiner" source is a special source # that can be used to join multiple sources together # and proxy call dispatch for each source # # Usage: # Smoke.join(:delicious, :twitter, :flickr) do # path :photos, :photo # end class Join < Origin # :nodoc: def initialize(names, &block) @names = names super((names << "joined").join("_").to_sym, &block) end # Rename sources immediately after they've been joined together # Usage: # Smoke.join(:delicious, :twitter, :flickr) do # name :web_stream # end def name(rename = nil) return @name if rename.nil? Smoke.rename(@name => rename) end def method_missing(symbol, *args, &block) ivar = "@#{symbol}" unless args.empty? sources.each do |source| source.last.instance_variable_set(ivar, args.last) end end return self end protected def sources Smoke.active_sources.find_all{|k, v| @names.include?(k) } end def dispatch # Recall dispatch sources.each do |source| source.last.send(:prepare!) source.last.send(:dispatch) if source.last.respond_to?(:dispatch) end # Re-map items @items = sources.map {|source| source.last.items }.flatten end end end end
Version data entries
6 entries across 6 versions & 2 rubygems