Class: Appsignal::Extension::MockData

Inherits:
Data show all
Defined in:
lib/appsignal/extension.rb

Overview

Mock of the Data class. This mock is used when the extension cannot be loaded. This mock listens to all method calls and does nothing, and prevents NoMethodErrors from being raised.

Disabled in testing so we can make sure that we don’t miss an extension function implementation.

This class inherits from the Data class so that it passes type checks.

Instance Method Summary collapse

Methods inherited from Data

#==, #append_boolean, #append_data, #append_float, #append_integer, #append_nil, #append_string, #inspect, #set_boolean, #set_data, #set_float, #set_integer, #set_nil, #set_string

Constructor Details

#initialize(*_args) ⇒ MockData

Returns a new instance of MockData.



87
88
89
90
# File 'lib/appsignal/extension.rb', line 87

def initialize(*_args)
  # JRuby extension requirement, as it sends a pointer to the Data object
  # when creating it
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(_method, *_args, &_block) ⇒ Object



92
93
94
# File 'lib/appsignal/extension.rb', line 92

def method_missing(_method, *_args, &_block)
  super if Appsignal.testing?
end

Instance Method Details

#to_sObject



96
97
98
# File 'lib/appsignal/extension.rb', line 96

def to_s
  "{}"
end