Module: Helper

Defined in:
lib/helper.rb

Overview

This module includes static methods that do not fall into cateogries. These are just helper methods for various algorithms throughout the source code.

Class Method Summary collapse

Class Method Details

.hash_to_sql(hash) ⇒ Object

Takes a hash and returns the conditions sql for an ActiveRecord find method



5
6
7
8
9
10
11
12
13
14
# File 'lib/helper.rb', line 5

def self.hash_to_sql(hash)
  conditions = Array.new
  hash.each do |attribute, term|
    conditions << "#{attribute} = ?"
  end
  sql_string = conditions.join(" and ")
  sql = [sql_string]
  hash.each { |attribute, term| sql << term }
  return sql
end