Class: Yell::Adapters::Collection
- Inherits:
-
Object
- Object
- Yell::Adapters::Collection
- Defined in:
- lib/yell/adapters.rb
Instance Method Summary collapse
- #add(type = :file, *args, &block) ⇒ Object
- #close ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(options = {}) ⇒ Collection
constructor
A new instance of Collection.
- #write(event) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Collection
Returns a new instance of Collection.
11 12 13 14 |
# File 'lib/yell/adapters.rb', line 11 def initialize( = {} ) @options = @collection = [] end |
Instance Method Details
#add(type = :file, *args, &block) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/yell/adapters.rb', line 16 def add( type = :file, *args, &block ) = [@options, *args].inject(Hash.new) do |h, c| h.merge( [String, Pathname].include?(c.class) ? {:filename => c} : c ) end # remove possible :null adapters @collection.shift if @collection.first.instance_of?(Yell::Adapters::Base) new_adapter = Yell::Adapters.new(type, , &block) @collection.push(new_adapter) new_adapter end |
#close ⇒ Object
41 42 43 |
# File 'lib/yell/adapters.rb', line 41 def close @collection.each { |c| c.close } end |
#empty? ⇒ Boolean
30 31 32 |
# File 'lib/yell/adapters.rb', line 30 def empty? @collection.empty? end |
#write(event) ⇒ Object
35 36 37 38 |
# File 'lib/yell/adapters.rb', line 35 def write( event ) @collection.each { |c| c.write(event) } true end |