module Sequel::Plugins::ForceEncoding::InstanceMethods

Private Instance Methods

_refresh_set_values(values) click to toggle source

Force the encoding of all string values when setting the instance’s values.

Calls superclass method
   # File lib/sequel/plugins/force_encoding.rb
49 def _refresh_set_values(values)
50   super(force_hash_encoding(values))
51 end
_save_set_values(values) click to toggle source

Force the encoding of all string values when setting the instance’s values.

Calls superclass method
   # File lib/sequel/plugins/force_encoding.rb
54 def _save_set_values(values)
55   super(force_hash_encoding(values))
56 end
force_hash_encoding(row) click to toggle source

Force the encoding for all string values in the given row hash.

   # File lib/sequel/plugins/force_encoding.rb
59 def force_hash_encoding(row)
60   if fe = model.forced_encoding
61     row.each_value{|v| v.force_encoding(fe) if v.is_a?(String) && !v.is_a?(Sequel::SQL::Blob)}
62   end
63   row
64 end
typecast_value(column, value) click to toggle source

Force the encoding of all returned strings to the model’s forced_encoding.

Calls superclass method
   # File lib/sequel/plugins/force_encoding.rb
67 def typecast_value(column, value)
68   s = super
69   if s.is_a?(String) && !s.is_a?(Sequel::SQL::Blob) && (fe = model.forced_encoding)
70     s = s.dup if s.frozen?
71     s.force_encoding(fe)
72   end
73   s
74 end