Class: ActiveRecord::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/inequal_opportunity.rb

Class Method Summary collapse

Class Method Details

.attribute_condition(quoted_column_name, argument) ⇒ Object



119
120
121
122
123
124
125
126
# File 'lib/inequal_opportunity.rb', line 119

def attribute_condition(quoted_column_name, argument)
  if argument.is_a? ActiveRecord::Inequality::Base
    question = argument.value.is_a?(Array) ? '(?)' : '?'
    "#{quoted_column_name} #{argument.operator} #{question}"
  else
    attribute_condition_orig(quoted_column_name, argument)
  end
end

.attribute_condition_origObject



118
# File 'lib/inequal_opportunity.rb', line 118

alias attribute_condition_orig attribute_condition

.expand_range_bind_variables(bind_vars) ⇒ Object



129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/inequal_opportunity.rb', line 129

def expand_range_bind_variables(bind_vars)
  expanded = []

  bind_vars.each do |var|
    next if var.is_a?(Hash)

    if var.is_a?(Range)
      expanded << var.first
      expanded << var.last
    elsif var.is_a?(ActiveRecord::Inequality::Base)
      expanded << var.value
    else
      expanded << var
    end
  end

  expanded
end

.expand_range_bind_variables_origObject



128
# File 'lib/inequal_opportunity.rb', line 128

alias expand_range_bind_variables_orig expand_range_bind_variables