Sha256: cdc41a4ae43550fd00cc4bbf2d2216766248b60d542c021db83dfb512e1db299
Contents?: true
Size: 1.1 KB
Versions: 4
Compression:
Stored size: 1.1 KB
Contents
module Ankh module Legacy module ActiveRecord def extended(base) base.class_attribute :_validators end def validates_with(*args, &block) _validators ||= {} options = args.extract_options! args.each do |klass| validator = klass.new(options, &block) validator.setup(self) if validator.respond_to?(:setup) if validator.respond_to?(:attributes) && !validator.attributes.empty? validator.attributes.each do |attribute| _validators[nil] ||= [] _validators[attribute.to_sym] << validator end else _validators[nil] ||= [] _validators[nil] << validator end validate(validator, options) end end private def _merge_attributes(attr_names) options = attr_names.extract_options! options.merge(:attributes => attr_names.flatten) end end end end unless ActiveRecord::Base.respond_to?(:validates_with) ActiveRecord::Base.extend Ankh::Legacy::ActiveRecord end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
ankh-0.1.3 | lib/ankh/rails/legacy.rb |
ankh-0.1.2 | lib/ankh/rails/legacy.rb |
ankh-0.1.1 | lib/ankh/rails/legacy.rb |
ankh-0.1.0 | lib/ankh/rails/legacy.rb |