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 end end end end