Class: AcraType

Inherits:
ActiveRecord::Type::String
  • Object
show all
Defined in:
lib/activerecord_acrawriter.rb

Instance Method Summary collapse

Instance Method Details

#cast(value) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/activerecord_acrawriter.rb', line 19

def cast(value)
  # scell can't encrypt null or empty objects
  if value.nil? or value == ''
    super
  else
    key = Base64.decode64(Rails.application.secrets.acra_public_key)
    ActiveRecord::Base.connection.escape_bytea(create_acrastruct(value.b, key))
  end
end

#deserialize(value) ⇒ Object



29
30
31
32
# File 'lib/activerecord_acrawriter.rb', line 29

def deserialize(value)
  # override to avoid call cast method
  value
end