Sha256: 579ff685671c346ab1285e6c22896d9ae1d7e291c0ada4d192e0ee21b73b28fe

Contents?: true

Size: 329 Bytes

Versions: 1

Compression:

Stored size: 329 Bytes

Contents

require 'activerecord'

module Coercionlogic
  def write_attribute_with_coercion(attr_name, value)
    value = nil if value.is_a?(String) && value.blank?
    write_attribute_without_coercion(attr_name, value)
  end
end

ActiveRecord::Base.class_eval do
  include Coercionlogic
  alias_method_chain :write_attribute, :coercion
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
coercionlogic-1.0.0 lib/coercionlogic.rb