Class: Factbase::Looged::Fact

Inherits:
Object
  • Object
show all
Defined in:
lib/factbase/looged.rb

Overview

Fact decorator.

This is an internal class, it is not supposed to be instantiated directly.

Constant Summary collapse

MAX_LENGTH =
64

Instance Method Summary collapse

Constructor Details

#initialize(fact, loog) ⇒ Fact

Returns a new instance of Fact.



73
74
75
76
# File 'lib/factbase/looged.rb', line 73

def initialize(fact, loog)
  @fact = fact
  @loog = loog
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*args) ⇒ Object



82
83
84
85
86
87
88
89
90
91
# File 'lib/factbase/looged.rb', line 82

def method_missing(*args)
  r = @fact.method_missing(*args)
  k = args[0].to_s
  v = args[1]
  s = v.is_a?(Time) ? v.utc.iso8601 : v.to_s
  s = v.to_s.inspect if v.is_a?(String)
  s = "#{s[0..MAX_LENGTH / 2]}...#{s[-MAX_LENGTH / 2..]}" if s.length > MAX_LENGTH
  @loog.debug("Set '#{k[0..-2]}' to #{s} (#{v.class})") if k.end_with?('=')
  r
end

Instance Method Details

#respond_to?(_method, _include_private = false) ⇒ Boolean

rubocop:disable Style/OptionalBooleanParameter

Returns:

  • (Boolean)


94
95
96
97
# File 'lib/factbase/looged.rb', line 94

def respond_to?(_method, _include_private = false)
  # rubocop:enable Style/OptionalBooleanParameter
  true
end

#respond_to_missing?(_method, _include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


99
100
101
# File 'lib/factbase/looged.rb', line 99

def respond_to_missing?(_method, _include_private = false)
  true
end

#to_sObject



78
79
80
# File 'lib/factbase/looged.rb', line 78

def to_s
  @fact.to_s
end