Class: Bumbleworks::Tracker

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, original_hash = nil) ⇒ Tracker

Returns a new instance of Tracker.



13
14
15
16
# File 'lib/bumbleworks/tracker.rb', line 13

def initialize(id, original_hash = nil)
  @id = id
  @original_hash = original_hash || Bumbleworks.dashboard.get_trackers[id]
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/bumbleworks/tracker.rb', line 3

def id
  @id
end

#original_hashObject (readonly)

Returns the value of attribute original_hash.



3
4
5
# File 'lib/bumbleworks/tracker.rb', line 3

def original_hash
  @original_hash
end

Class Method Details

.allObject



6
7
8
9
10
# File 'lib/bumbleworks/tracker.rb', line 6

def all
  Bumbleworks.dashboard.get_trackers.map do |tid, attrs|
    new(tid, attrs)
  end
end

Instance Method Details

#actionObject



40
41
42
# File 'lib/bumbleworks/tracker.rb', line 40

def action
  @original_hash['action']
end

#conditionsObject



32
33
34
# File 'lib/bumbleworks/tracker.rb', line 32

def conditions
  @original_hash['conditions'] || {}
end

#global?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/bumbleworks/tracker.rb', line 28

def global?
  @original_hash['wfid'].nil?
end

#processObject



22
23
24
25
26
# File 'lib/bumbleworks/tracker.rb', line 22

def process
  if wfid_from_hash = wfid
    Bumbleworks::Process.new(wfid_from_hash)
  end
end

#tagsObject



36
37
38
# File 'lib/bumbleworks/tracker.rb', line 36

def tags
  [conditions['tag']].flatten.compact
end

#waiting_expressionObject



44
45
46
47
# File 'lib/bumbleworks/tracker.rb', line 44

def waiting_expression
  return nil unless fei
  process.expressions.detect { |e| e.fei.expid == fei['expid'] }.tree
end

#wfidObject



18
19
20
# File 'lib/bumbleworks/tracker.rb', line 18

def wfid
  wfid = fei ? fei['wfid'] : @original_hash['wfid']
end

#where_clauseObject



49
50
51
52
53
# File 'lib/bumbleworks/tracker.rb', line 49

def where_clause
  we = waiting_expression
  return nil unless we
  we[1]['where']
end