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.



40
41
42
# File 'lib/green_log/entry.rb', line 40

def initialize(severity)
  @severity = severity
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



46
47
48
# File 'lib/green_log/entry.rb', line 46

def data
  @data
end

#exceptionObject

Returns the value of attribute exception.



47
48
49
# File 'lib/green_log/entry.rb', line 47

def exception
  @exception
end

#messageObject

Returns the value of attribute message.



45
46
47
# File 'lib/green_log/entry.rb', line 45

def message
  @message
end

#severityObject (readonly)

Returns the value of attribute severity.



44
45
46
# File 'lib/green_log/entry.rb', line 44

def severity
  @severity
end

Instance Method Details

#build(*args, &block) ⇒ Object



67
68
69
70
71
72
73
74
75
76
77
# File 'lib/green_log/entry.rb', line 67

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