Class: FileWatch::ReadMode::Handlers::Base

Inherits:
Object
  • Object
show all
Includes:
LogStash::Util::Loggable
Defined in:
lib/filewatch/read_mode/handlers/base.rb

Direct Known Subclasses

ReadFile, ReadZipFile

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sincedb_collection, observer, settings) ⇒ Base

Returns a new instance of Base.



10
11
12
13
14
# File 'lib/filewatch/read_mode/handlers/base.rb', line 10

def initialize(sincedb_collection, observer, settings)
  @settings = settings
  @sincedb_collection = sincedb_collection
  @observer = observer
end

Instance Attribute Details

#sincedb_collectionObject (readonly)

Returns the value of attribute sincedb_collection.



8
9
10
# File 'lib/filewatch/read_mode/handlers/base.rb', line 8

def sincedb_collection
  @sincedb_collection
end

Instance Method Details

#handle(watched_file) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/filewatch/read_mode/handlers/base.rb', line 16

def handle(watched_file)
  logger.debug("handling: #{watched_file.path}")
  unless watched_file.has_listener?
    watched_file.set_listener(@observer)
  end
  handle_specifically(watched_file)
end

#handle_specifically(watched_file) ⇒ Object



24
25
26
# File 'lib/filewatch/read_mode/handlers/base.rb', line 24

def handle_specifically(watched_file)
  # some handlers don't need to define this method
end