Sha256: 13ab80ed30be254a3a9bf1b9e60ab0d515fc1f82d0be743f97ee18803de32ced

Contents?: true

Size: 509 Bytes

Versions: 1

Compression:

Stored size: 509 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
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bikepoa-tools-0.3.0 lib/bikepoa/helpers.rb