Class: Smoke::Join

Inherits:
Origin show all
Defined in:
lib/smoke/source/join.rb

Overview

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

Instance Attribute Summary

Attributes inherited from Origin

#exposed, #items, #requirements

Instance Method Summary collapse

Methods inherited from Origin

#conceal, #concealed?, #discard, #emit, #expose, #exposed?, #insert, #keep, #output, #path, #prepare, #rename, #reverse, #sort, #transform, #truncate

Constructor Details

#initialize(names, &block) ⇒ Join

:nodoc:



11
12
13
14
# File 'lib/smoke/source/join.rb', line 11

def initialize(names, &block)
  @names = names
  super((names << "joined").join("_").to_sym, &block)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(symbol, *args, &block) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/smoke/source/join.rb', line 26

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

Instance Method Details

#name(rename = nil) ⇒ Object

Rename sources immediately after they’ve been joined together Usage:

Smoke.join(:delicious, :twitter, :flickr) do
  name :web_stream
end


21
22
23
24
# File 'lib/smoke/source/join.rb', line 21

def name(rename = nil)
  return @name if rename.nil?
  Smoke.rename(@name => rename)
end