Sha256: c093f35d5be8ec2032e3593b9f3b50c23a183ab1f8c1e6b73cec7fb290dc58ac

Contents?: true

Size: 907 Bytes

Versions: 3

Compression:

Stored size: 907 Bytes

Contents

module Kindergarten::ORM
  module ActiveRecord
    def self.included(base)
      base.extend(ClassMethods)
    end

    def update_attributes(hash)
      self.class.check(:update_attributes, hash)
    end

    module ClassMethods
      def create(*args)
        check(:create, *args)
        super
      end

      def new(*args)
        check(:new, *args)
        super
      end

      def check(method, *args)
        required = self.force_rinsed? ?
          Kindergarten::RinsedHash :
          Kindergarten::ScrubbedHash

        if args[0].is_a?(Array)
          args.each do |input|
            raise Unscrubbed unless input.is_a?(required)
          end

        elsif args[0].is_a?(Hash)
          raise Unscrubbed unless args[0].is_a?(required)

        elsif args.any?
          Kindergarten.warning "#{self.name}.#{method} called with unkown signature"

        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
kindergarten-0.2.1 lib/kindergarten/orm/active_record.rb
kindergarten-0.2.0 lib/kindergarten/orm/active_record.rb
kindergarten-0.1.1 lib/kindergarten/orm/active_record.rb