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.
14 15 16 17 |
# File 'lib/yell/adapters.rb', line 14 def initialize( = {} ) @options = @collection = [] end |
Instance Method Details
#add(type = :file, *args, &block) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/yell/adapters.rb', line 19 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
44 45 46 |
# File 'lib/yell/adapters.rb', line 44 def close @collection.each { |c| c.close } end |
#empty? ⇒ Boolean
33 34 35 |
# File 'lib/yell/adapters.rb', line 33 def empty? @collection.empty? end |
#write(event) ⇒ Object
38 39 40 41 |
# File 'lib/yell/adapters.rb', line 38 def write( event ) @collection.each { |c| c.write(event) } true end |