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.



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

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



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

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)


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

def respond_to?(method, include_private = false)
  # rubocop:enable Style/OptionalBooleanParameter
  @fact.respond_to?(method, include_private)
end

#respond_to_missing?(method, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


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

def respond_to_missing?(method, include_private = false)
  @fact.respond_to_missing?(method, include_private)
end

#to_sObject



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

def to_s
  @fact.to_s
end