Class: Carnivore::Source::SourceContainer
- Inherits:
-
Object
- Object
- Carnivore::Source::SourceContainer
- Defined in:
- lib/carnivore/source_container.rb
Overview
Container for holding source configuration. This allows setup to occur prior to the supervisor actually starting the sources
Instance Attribute Summary (collapse)
-
- (Class) klass
readonly
Class of Source.
-
- (Hash) source_hash
readonly
Configuration hash for Source.
Instance Method Summary (collapse)
-
- (Class, Proc) add_callback(name, klass = nil) {|message| ... }
name
Name of callback klass
Class of callback (optional) Add a callback to a source via Class or block.
-
- (SourceContainer) initialize(class_name, args = {})
constructor
Create a new source container.
Constructor Details
- (SourceContainer) initialize(class_name, args = {})
Create a new source container
19 20 21 22 23 |
# File 'lib/carnivore/source_container.rb', line 19 def initialize(class_name, args={}) @klass = class_name @source_hash = Smash.new(args || {}) @source_hash[:callbacks] = Smash.new end |
Instance Attribute Details
- (Class) klass (readonly)
Returns class of Source
11 12 13 |
# File 'lib/carnivore/source_container.rb', line 11 def klass @klass end |
- (Hash) source_hash (readonly)
Returns configuration hash for Source
13 14 15 |
# File 'lib/carnivore/source_container.rb', line 13 def source_hash @source_hash end |
Instance Method Details
- (Class, Proc) add_callback(name, klass = nil) {|message| ... }
name |
Name of callback |
klass |
Class of callback (optional) |
Add a callback to a source via Class or block
34 35 36 |
# File 'lib/carnivore/source_container.rb', line 34 def add_callback(name, klass=nil, &block) @source_hash[:callbacks][name] = klass || block end |