class AcraType
Public Instance Methods
serialize(value)
click to toggle source
# File lib/activerecord_acrawriter.rb, line 20 def serialize(value) return '' if value.to_s.empty? key = Base64.decode64(Rails.application.secrets.acra_public_key) acrastruct = create_acrastruct(value.b, key) case ActiveRecord::Base.connection.adapter_name when 'PostgreSQL' return ActiveRecord::Base.connection.escape_bytea(acrastruct) when 'Mysql2' return acrastruct.b end raise 'Do not know how to operate with adapter ' + ActiveRecord::Base.connection.adapter_name end
Private Instance Methods
cast_value(value)
click to toggle source
# File lib/activerecord_acrawriter.rb, line 39 def cast_value(value) return '' if value.to_s.empty? case ActiveRecord::Base.connection.adapter_name when 'PostgreSQL' return [value[2..-1]].pack('H*') if value.start_with?('\x') return value.to_s when 'Mysql2' return value.to_s end raise 'Do not know how to operate with adapter ' + ActiveRecord::Base.connection.adapter_name end