Sha256: fec2ba9ed14804409ea76fd72f76c5a56574b96653dd011340c3a0a1becc77ae

Contents?: true

Size: 1.69 KB

Versions: 5

Compression:

Stored size: 1.69 KB

Contents

module ThinkingSphinx
  module HashExcept
    # Returns a new hash without the given keys.
    def except(*keys)
      rejected = Set.new(respond_to?(:convert_key) ? keys.map { |key| convert_key(key) } : keys)
      reject { |key,| rejected.include?(key) }
    end

    # Replaces the hash without only the given keys.
    def except!(*keys)
      replace(except(*keys))
    end
  end
end

Hash.send(
  :include, ThinkingSphinx::HashExcept
) unless Hash.instance_methods.include?("except")

module ThinkingSphinx
  module ArrayExtractOptions
    def extract_options!
      last.is_a?(::Hash) ? pop : {}
    end
  end
end

Array.send(
  :include, ThinkingSphinx::ArrayExtractOptions
) unless Array.instance_methods.include?("extract_options!")

module ThinkingSphinx
  module MysqlQuotedTableName
    def quote_table_name(name) #:nodoc:
      quote_column_name(name).gsub('.', '`.`')
    end
  end
end

if ActiveRecord::ConnectionAdapters.constants.include?("MysqlAdapter")
  ActiveRecord::ConnectionAdapters::MysqlAdapter.send(
    :include, ThinkingSphinx::MysqlQuotedTableName
  ) unless ActiveRecord::ConnectionAdapters::MysqlAdapter.instance_methods.include?("quote_table_name")
end

module ThinkingSphinx
  module ActiveRecordQuotedName
    def quoted_table_name
      self.connection.quote_table_name(self.table_name)
    end 
  end
end

ActiveRecord::Base.extend(
  ThinkingSphinx::ActiveRecordQuotedName
) unless ActiveRecord::Base.respond_to?("quoted_table_name")

module ThinkingSphinx
  module ActiveRecordStoreFullSTIClass
    def store_full_sti_class
      false
    end
  end
end

ActiveRecord::Base.extend(
  ThinkingSphinx::ActiveRecordStoreFullSTIClass
) unless ActiveRecord::Base.respond_to?(:store_full_sti_class)

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
freelancing-god-thinking-sphinx-0.9.10 lib/thinking_sphinx/rails_additions.rb
freelancing-god-thinking-sphinx-0.9.11 lib/thinking_sphinx/rails_additions.rb
freelancing-god-thinking-sphinx-0.9.12 lib/thinking_sphinx/rails_additions.rb
freelancing-god-thinking-sphinx-0.9.13 lib/thinking_sphinx/rails_additions.rb
jaikoo-thinking-sphinx-0.9.10 lib/thinking_sphinx/rails_additions.rb