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, line 50
def _refresh_set_values(values)
  super(force_hash_encoding(values))
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, line 55
def _save_set_values(values)
  super(force_hash_encoding(values))
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, line 60
def force_hash_encoding(row)
  if fe = model.forced_encoding
    row.each_value{|v| v.force_encoding(fe) if v.is_a?(String) && !v.is_a?(Sequel::SQL::Blob)}
  end
  row
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, line 68
def typecast_value(column, value)
  s = super
  if s.is_a?(String) && !s.is_a?(Sequel::SQL::Blob) && (fe = model.forced_encoding)
    s = s.dup if s.frozen?
    s.force_encoding(fe)
  end
  s
end