Sha256: 364a2221eebe62604ef3cbe481495eeab8618c8a808dfcd62ce18a6e9f2ed2df

Contents?: true

Size: 1.25 KB

Versions: 3

Compression:

Stored size: 1.25 KB

Contents

module Datagrid
  module Drivers
    class AbstractDriver

      class_attribute :subclasses

      def self.inherited(base)
        super(base)
        self.subclasses ||= []
        self.subclasses << base
      end

      def self.guess_driver(scope)
        klass = self.subclasses.find do |driver_class|
          driver_class.match?(scope)
        end || raise(Datagrid::ConfigurationError, "ORM Driver not found for scope: #{scope.inspect}.")
      end


      def self.match?(scope)
        raise NotImplementedError
      end

      def to_scope(scope)
        raise NotImplementedError
      end

      def where(scope, condition)
        raise NotImplementedError
      end

      def asc(scope, order)
        raise NotImplementedError
      end

      def desc(scope, order)
        raise NotImplementedError
      end

      def default_order(scope, column_name)
        raise NotImplementedError
      end

      def greater_equal(scope, field, value)
        raise NotImplementedError
      end

      def less_equal(scope, field, value)
        raise NotImplementedError
      end
      
      def has_column?(scope, column_name)
        raise NotImplementedError
      end

      def reverse_order(scope)
        raise NotImplementedError
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
datagrid-0.8.0 lib/datagrid/drivers/abstract_driver.rb
datagrid-0.7.1 lib/datagrid/drivers/abstract_driver.rb
datagrid-0.7.0 lib/datagrid/drivers/abstract_driver.rb