Class: Factbase::Rules::Fact

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

Overview

Fact decorator.

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

Instance Method Summary collapse

Constructor Details

#initialize(fact, check) ⇒ Fact

Returns a new instance of Fact.



69
70
71
72
# File 'lib/factbase/rules.rb', line 69

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

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*args) ⇒ Object



78
79
80
81
82
83
# File 'lib/factbase/rules.rb', line 78

def method_missing(*args)
  r = @fact.method_missing(*args)
  k = args[0].to_s
  @check.it(self) if k.end_with?('=')
  r
end

Instance Method Details

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

rubocop:disable Style/OptionalBooleanParameter

Returns:

  • (Boolean)


86
87
88
89
# File 'lib/factbase/rules.rb', line 86

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)


91
92
93
# File 'lib/factbase/rules.rb', line 91

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

#to_sObject



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

def to_s
  @fact.to_s
end