Module: Appsignal::Extension::Jruby::StringHelpers Private
- Included in:
- Appsignal::Extension::Jruby, Data, Span, Span, Transaction
- Defined in:
- lib/appsignal/extension/jruby.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
JRuby extension String helpers.
Based on the make_appsignal_string and make_ruby_string helpers from the AppSignal C-extension in ‘ext/appsignal_extension.c`.
Defined Under Namespace
Classes: AppsignalString
Instance Method Summary collapse
- #make_appsignal_string(ruby_string) ⇒ Object private
- #make_ruby_string(appsignal_string) ⇒ Object private
Instance Method Details
#make_appsignal_string(ruby_string) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
25 26 27 28 29 30 31 32 |
# File 'lib/appsignal/extension/jruby.rb', line 25 def make_appsignal_string(ruby_string) raise ArgumentError, "argument is not a string" unless ruby_string.is_a?(String) AppsignalString.new.tap do |appsignal_string| appsignal_string[:len] = ruby_string.bytesize appsignal_string[:buf] = FFI::MemoryPointer.from_string(ruby_string) end end |
#make_ruby_string(appsignal_string) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
34 35 36 37 38 |
# File 'lib/appsignal/extension/jruby.rb', line 34 def make_ruby_string(appsignal_string) appsignal_string[:buf].read_string(appsignal_string[:len]).tap do |ruby_string| ruby_string.force_encoding(Encoding::UTF_8) end end |