Class: Hope::Listener::Base

Inherits:
Object show all
Includes:
UpdateListener
Defined in:
lib/hope/listener/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, *args) ⇒ Base

Returns a new instance of Base.



11
12
13
14
# File 'lib/hope/listener/base.rb', line 11

def initialize name, *args
  puts "Initialized new Listener: #{self.class.name}, with args: #{args.inspect}"
  @name = name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



9
10
11
# File 'lib/hope/listener/base.rb', line 9

def name
  @name
end

Instance Method Details

#serializable_hashObject



31
32
33
34
35
36
# File 'lib/hope/listener/base.rb', line 31

def serializable_hash
  {
    :id => name,
    :name => name
  }
end

#update(newEvents, oldEvents) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/hope/listener/base.rb', line 16

def update(newEvents, oldEvents)
  newEvents.each do |event|
    puts "[#{@name}] New event (#{event.getUnderlying.class}): #{event.getUnderlying.toString rescue event.getUnderlying.inspect}"
  end unless newEvents.nil?
  
  unless oldEvents.nil?
    oldEvents.each do |event|
      puts "[#{@name}] Old Event (#{event.getUnderlying.class}): #{event.getUnderlying.toString rescue event.getUnderlying.inspect}"
    end 
  else
    puts "NO oldEvents here..."
  end
  
end