Sha256: 98dfbdab8cfeb1be02bcb36b9707a9fbae64f0b4bccc82ac77b2bac70292725d

Contents?: true

Size: 864 Bytes

Versions: 13

Compression:

Stored size: 864 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.new{ where("1=0") }
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
protector-0.6.4 lib/protector/adapters/sequel.rb
protector-0.6.3 lib/protector/adapters/sequel.rb
protector-0.6.2 lib/protector/adapters/sequel.rb
protector-0.6.1 lib/protector/adapters/sequel.rb
protector-0.6.0 lib/protector/adapters/sequel.rb
protector-0.6.0.beta.1 lib/protector/adapters/sequel.rb
protector-0.5.5 lib/protector/adapters/sequel.rb
protector-0.5.4 lib/protector/adapters/sequel.rb
protector-0.5.3 lib/protector/adapters/sequel.rb
protector-0.5.2 lib/protector/adapters/sequel.rb
protector-0.5.1 lib/protector/adapters/sequel.rb
protector-0.4.1 lib/protector/adapters/sequel.rb
protector-0.4.0 lib/protector/adapters/sequel.rb