Module: BikePOA::Helpers::ForceField::Enforcers

Defined in:
lib/bikepoa/helpers.rb

Class Method Summary collapse

Class Method Details

.force_integer(value) ⇒ Object



24
25
26
# File 'lib/bikepoa/helpers.rb', line 24

def self.force_integer(value)
  Integer(value)
end

.force_utf8(value) ⇒ Object



28
29
30
31
32
33
34
35
# File 'lib/bikepoa/helpers.rb', line 28

def self.force_utf8(value)
  begin
    value.encode('iso-8859-1','utf-8') # a iso-8859-1 would raise here!
    value
  rescue Encoding::InvalidByteSequenceError
    value.encode('utf-8','iso-8859-1')
  end
end