class Adalog::Entry
Attributes
details[R]
errors[R]
message[R]
timestamp[R]
title[R]
Public Class Methods
build(obj = nil, **options)
click to toggle source
# File lib/adalog/entry.rb, line 7 def self.build(obj = nil, **options) arguments = if nil == obj options elsif obj.is_a?(Hash) || obj.respond_to?(:[]) obj elsif obj.respond_to?(:to_h) obj.to_h.merge(options) else { title: obj.respond_to?(:title) && obj.title, timestamp: obj.respond_to?(:timestamp) && obj.timestamp, message: obj.respond_to?(:message) && obj.message, details: obj.respond_to?(:details) && obj.details, format: obj.respond_to?(:format) && obj.format, }.merge(options) end self.new( title: arguments[:title] || arguments['title'], timestamp: arguments[:timestamp] || arguments['timestamp'], message: arguments[:message] || arguments['message'], details: arguments[:details] || arguments['details'], format: arguments[:format] || arguments['format'], ) end
new(title: nil, timestamp: nil, message: nil, details: nil, format: nil)
click to toggle source
# File lib/adalog/entry.rb, line 35 def initialize(title: nil, timestamp: nil, message: nil, details: nil, format: nil) @title = title || '' @timestamp = timestamp || Time.now @message = message || '' @details = details || '' @format = format || 'json' validate! end
Public Instance Methods
details_blank?()
click to toggle source
# File lib/adalog/entry.rb, line 56 def details_blank? blank?(details) end
format()
click to toggle source
TODO: Make this something we store and/or can override.
# File lib/adalog/entry.rb, line 51 def format :json end
valid?()
click to toggle source
# File lib/adalog/entry.rb, line 45 def valid? @errors.none? end