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 48
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 53
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 58
def force_hash_encoding(row)
  fe = model.forced_encoding
  row.values.each{|v| v.force_encoding(fe) if v.is_a?(String)} if fe
  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 65
def typecast_value(column, value)
  s = super
  if s.is_a?(String) && (fe = model.forced_encoding)
    s = s.dup if s.frozen?
    s.force_encoding(fe)
  end
  s
end