Class: GreenLog::Entry::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/green_log/entry.rb

Overview

A builder for entries.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(severity) ⇒ Builder

Returns a new instance of Builder.



59
60
61
# File 'lib/green_log/entry.rb', line 59

def initialize(severity)
  @severity = severity
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



65
66
67
# File 'lib/green_log/entry.rb', line 65

def data
  @data
end

#exceptionObject

Returns the value of attribute exception.



66
67
68
# File 'lib/green_log/entry.rb', line 66

def exception
  @exception
end

#messageObject

Returns the value of attribute message.



64
65
66
# File 'lib/green_log/entry.rb', line 64

def message
  @message
end

#severityObject (readonly)

Returns the value of attribute severity.



63
64
65
# File 'lib/green_log/entry.rb', line 63

def severity
  @severity
end

Instance Method Details

#build(*args, &block) ⇒ Object



86
87
88
89
90
91
92
93
94
95
96
# File 'lib/green_log/entry.rb', line 86

def build(*args, &block)
  args.each(&method(:handle_arg))
  if block
    if block.arity.zero?
      Array(block.call).each(&method(:handle_arg))
    else
      block.call(self)
    end
  end
  Entry.with(severity: severity, message: message, data: data, exception: exception)
end