Sha256: a26f57a1adc77d073f4babae4bba1ec4f8a8a133fc43f8c6bc2739b4fb750a9a

Contents?: true

Size: 693 Bytes

Versions: 1

Compression:

Stored size: 693 Bytes

Contents

require 'green_eggs_and_spam/anti_spam_validator'

module GreenEggsAndSpam  
  
  module ActiveRecord
    
    # Adds the `validates_anti_spam` method into ActiveRecord::Base
    def self.included(base)
      base.extend GreenEggsAndSpam::ActiveRecord::ClassMethods
    end
    
    module ClassMethods
    
      # Installs GreenEggsAndSpam's validation functionality into the supplied model
      def validates_anti_spam
        self.class_eval do
          attr_accessor :antispam
          validates_with GreenEggsAndSpam::AntiSpamValidator
        end
      end
      
    end
    
  end
  
end

ActiveRecord::Base.send(:include, GreenEggsAndSpam::ActiveRecord) if defined?(ActiveRecord)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
green_eggs_and_spam-0.2.0 lib/green_eggs_and_spam/active_record.rb