Sha256: 5124b62cd1c9ffd101b495215d9f9d10fea9a1073cc18252d3d8829efd0e02a5
Contents?: true
Size: 877 Bytes
Versions: 27
Compression:
Stored size: 877 Bytes
Contents
module ActiveTools module ActiveRecord module FilterAssign extend ::ActiveSupport::Concern included do end module ClassMethods def filter_assign(*args) options = args.extract_options! args.each do |attribute| define_method "#{attribute}=" do |value| if (options[:if].nil? || (options[:if].is_a?(Proc) && options[:if].call(value) == true)) && (options[:unless].nil? || (options[:unless].is_a?(Proc) && options[:unless].call(value) == false)) if options.has_key?(:force_value) super(options[:force_value]) end else super(value) end end end end end end end module OnLoadActiveRecord include ActiveRecord::FilterAssign end end
Version data entries
27 entries across 27 versions & 1 rubygems