Sha256: d3a8e453908a2280e5314e77010ce855432b35e53ae3d2042a36f6756bb5e3d8

Contents?: true

Size: 778 Bytes

Versions: 4

Compression:

Stored size: 778 Bytes

Contents

# encoding: utf-8

module EdgeRider
  module Util
    extend self

    def qualify_column_name(model, column_name)
      column_name = column_name.to_s
      unless column_name.include?('.')
        quoted_table_name = model.connection.quote_table_name(model.table_name)
        quoted_column_name = model.connection.quote_column_name(column_name)
        column_name = "#{quoted_table_name}.#{quoted_column_name}"
      end
      column_name
    end

    def exclusive_query(model, conditions)
      if Rails.version < '3'
        model.send(:with_exclusive_scope) do
          model.scoped(:conditions => conditions)
        end
      else
        model.unscoped.where(conditions)
      end
    end

    def scope?(object)
      object.respond_to?(:scoped)
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
edge_rider-0.2.2 lib/edge_rider/util.rb
edge_rider-0.2.1 lib/edge_rider/util.rb
edge_rider-0.2.0 lib/edge_rider/util.rb
edge_rider-0.1.1 lib/edge_rider/util.rb