Sha256: 857bd7adead293fa3a2ebc43561c36e54b686542357e3976a91bd006a1d0c482
Contents?: true
Size: 749 Bytes
Versions: 1
Compression:
Stored size: 749 Bytes
Contents
module BikePOA module Helpers module ForceField FORCED_FIELDS = {} def self.included(base) base.send :extend, ClassMethods end def []=(property, value) transform = FORCED_FIELDS[property.to_sym] value = transform.call(value) if transform super(property, value) end module ClassMethods def force_integer(field) FORCED_FIELDS[field.to_sym] = lambda { |value| Integer(value) } end def force_utf8(field) FORCED_FIELDS[field.to_sym] = lambda do |value| new_value = value.encode('utf-8','iso-8859-1') (new_value.length == value.length)? new_value : value end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bikepoa-tools-0.3.1 | lib/bikepoa/helpers.rb |