Class: GCSIOWriter

Inherits:
Object
  • Object
show all
Defined in:
lib/logstash/outputs/google_cloud_storage.rb

Overview

Wrapper class that abstracts which IO being used (for instance, regular files or GzipWriter.

Inspired by lib/logstash/outputs/file.rb.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(io) ⇒ GCSIOWriter

Returns a new instance of GCSIOWriter.



405
406
407
# File 'lib/logstash/outputs/google_cloud_storage.rb', line 405

def initialize(io)
  @io = io
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &block) ⇒ Object



419
420
421
422
423
424
425
426
427
428
429
# File 'lib/logstash/outputs/google_cloud_storage.rb', line 419

def method_missing(method_name, *args, &block)
  if @io.respond_to?(method_name)
    @io.send(method_name, *args, &block)
  else
    if @io.class == Zlib::GzipWriter && @io.to_io.respond_to?(method_name)
      @io.to_io.send(method_name, *args, &block)
    else
      super
    end
  end
end

Instance Attribute Details

#activeObject

Returns the value of attribute active.



430
431
432
# File 'lib/logstash/outputs/google_cloud_storage.rb', line 430

def active
  @active
end

Instance Method Details

#fsyncObject



411
412
413
414
415
416
417
418
# File 'lib/logstash/outputs/google_cloud_storage.rb', line 411

def fsync
  if @io.class == Zlib::GzipWriter
    @io.flush
    @io.to_io.fsync
  else
    @io.fsync
  end
end

#write(*args) ⇒ Object



408
409
410
# File 'lib/logstash/outputs/google_cloud_storage.rb', line 408

def write(*args)
  @io.write(*args)
end