Sha256: de1fe642594871f80a790ed7c22f8c63be4950a7f9dbc8ca309106b2a34c1cd1

Contents?: true

Size: 862 Bytes

Versions: 7

Compression:

Stored size: 862 Bytes

Contents

require 'protector/adapters/sequel/model'
require 'protector/adapters/sequel/dataset'
require 'protector/adapters/sequel/eager_graph_loader'

module Protector
  module Adapters
    # Sequel adapter
    module Sequel
      # YIP YIP! Monkey-Patch the Sequel.
      def self.activate!
        return false unless defined?(::Sequel)

        ::Sequel::Model.send :include, Protector::Adapters::Sequel::Model
        ::Sequel::Dataset.send :include, Protector::Adapters::Sequel::Dataset
        ::Sequel::Model::Associations::EagerGraphLoader.send :include, Protector::Adapters::Sequel::EagerGraphLoader
      end

      def self.is?(instance)
        instance.kind_of?(::Sequel::Dataset) ||
        (instance.kind_of?(Class) && instance < ::Sequel::Model)
      end

      def self.null_proc
        @null_proc ||= proc { where('1=0') }
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
protector-0.7.7 lib/protector/adapters/sequel.rb
protector-0.7.6 lib/protector/adapters/sequel.rb
protector-0.7.4 lib/protector/adapters/sequel.rb
protector-0.7.3 lib/protector/adapters/sequel.rb
protector-0.7.2 lib/protector/adapters/sequel.rb
protector-0.7.1 lib/protector/adapters/sequel.rb
protector-0.7.0 lib/protector/adapters/sequel.rb