module Demoji
Constants
- VERSION
Private Instance Methods
_fix_chars(str)
click to toggle source
# File lib/demoji.rb, line 39 def _fix_chars(str) "".tap do |out_str| # for instead of split and joins for perf for i in (0...str.length) char = str[i] char = 32.chr if char.ord > 65535 out_str << char end end end
_fix_utf8_attributes()
click to toggle source
# File lib/demoji.rb, line 32 def _fix_utf8_attributes self.attributes.each do |k, v| next if v.blank? || !v.is_a?(String) || (self.column_for_attribute(k).type == :binary) self.send "#{k}=", _fix_chars(v) end end
create_or_update(*)
Also aliased as: create_or_update_without_utf8_rescue
Alias for: create_or_update_with_utf8_rescue
create_or_update_with_utf8_rescue(*)
click to toggle source
# File lib/demoji.rb, line 17 def create_or_update_with_utf8_rescue(*) _rescued_counter ||= 0 create_or_update_without_utf8_rescue rescue ActiveRecord::StatementInvalid => ex raise ex unless ex.message.match /Mysql2::Error: Incorrect string value:/ _rescued_counter += 1 raise ex if _rescued_counter > 1 _fix_utf8_attributes retry end
Also aliased as: create_or_update