Class: GoodData::Bam::DSL::FlowDSL

Inherits:
Object
  • Object
show all
Defined in:
lib/dsl/dsl.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data = {}, &bl) ⇒ FlowDSL

Returns a new instance of FlowDSL.



13
14
15
16
17
18
19
20
# File 'lib/dsl/dsl.rb', line 13

def initialize(data={}, &bl)
  fail "Flows params needs a hash" unless data.is_a? Hash
  name = data[:id]
  fail "Flow needs to have a name" if name.blank?
  @name = name
  @steps = []
  instance_eval(&bl)
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



11
12
13
# File 'lib/dsl/dsl.rb', line 11

def name
  @name
end

#stepsObject (readonly)

Returns the value of attribute steps.



11
12
13
# File 'lib/dsl/dsl.rb', line 11

def steps
  @steps
end

Instance Method Details

#graph(data, &bl) ⇒ Object



32
33
34
35
36
37
38
39
40
41
# File 'lib/dsl/dsl.rb', line 32

def graph(data, &bl)
  fail "Params for graph need to be hash" unless data.is_a? Hash
  # @steps << {:type => :graph , :flow_id => @name}.merge(data)
  if bl.nil?
    @steps << {:type => :graph, :steps => [], :flow_id => @name}.merge(data)
  else
     = GraphDSL.new(@name, &bl)
    @steps << {:type => :graph, :steps => .to_a, :flow_id => @name}.merge(data)
  end
end

#sink(data = {}) ⇒ Object



27
28
29
30
# File 'lib/dsl/dsl.rb', line 27

def sink(data={})
  fail "Params for tap need to be hash" unless data.is_a? Hash
  @steps << {:type => :sink , :flow_id => @name}.merge(data)
end

#tap(data = {}) ⇒ Object



22
23
24
25
# File 'lib/dsl/dsl.rb', line 22

def tap(data={})
  fail "Params for tap need to be hash" unless data.is_a? Hash
  @steps << {:type => :tap, :flow_id => @name}.merge(data)
end

#to_hashObject



43
44
45
46
47
48
# File 'lib/dsl/dsl.rb', line 43

def to_hash
  {
    :name => @name,
    :steps => @steps
  }
end