module Quiver::Adapter::ActiveRecordAdapterFilterDefaults

Public Class Methods

included(host) click to toggle source
# File lib/quiver/adapter/active_record_adapter_filter.rb, line 6
def self.included(host)
  host.extend(ClassMethods)
end

Public Instance Methods

equal_filter(memo, attr, value) click to toggle source
# File lib/quiver/adapter/active_record_adapter_filter.rb, line 27
def equal_filter(memo, attr, value)
  memo.where(hash_style_attr(attr, value))
end
greater_than_filter(memo, attr, value) click to toggle source
# File lib/quiver/adapter/active_record_adapter_filter.rb, line 47
def greater_than_filter(memo, attr, value)
  memo.where("#{string_style_attr(attr)} > ?", value)
end
greater_than_or_equal_filter(memo, attr, value) click to toggle source
# File lib/quiver/adapter/active_record_adapter_filter.rb, line 55
def greater_than_or_equal_filter(memo, attr, value)
  memo.where("#{string_style_attr(attr)} >= ?", value)
end
in_filter(memo, attr, value) click to toggle source
# File lib/quiver/adapter/active_record_adapter_filter.rb, line 35
def in_filter(memo, attr, value)
  memo.where(hash_style_attr(attr, value))
end
less_than_filter(memo, attr, value) click to toggle source
# File lib/quiver/adapter/active_record_adapter_filter.rb, line 43
def less_than_filter(memo, attr, value)
  memo.where("#{string_style_attr(attr)} < ?", value)
end
less_than_or_equal_filter(memo, attr, value) click to toggle source
# File lib/quiver/adapter/active_record_adapter_filter.rb, line 51
def less_than_or_equal_filter(memo, attr, value)
  memo.where("#{string_style_attr(attr)} <= ?", value)
end
nil_filter(memo, attr, value) click to toggle source
# File lib/quiver/adapter/active_record_adapter_filter.rb, line 59
def nil_filter(memo, attr, value)
  if value == 'true' || value == true
    memo.where("#{string_style_attr(attr)} IS NULL")
  else
    memo.where("#{string_style_attr(attr)} IS NOT NULL")
  end
end
not_equal_filter(memo, attr, value) click to toggle source
# File lib/quiver/adapter/active_record_adapter_filter.rb, line 31
def not_equal_filter(memo, attr, value)
  memo.where.not(hash_style_attr(attr, value))
end
not_in_filter(memo, attr, value) click to toggle source
# File lib/quiver/adapter/active_record_adapter_filter.rb, line 39
def not_in_filter(memo, attr, value)
  memo.where.not(hash_style_attr(attr, value))
end
not_nil_filter(memo, attr, value) click to toggle source
# File lib/quiver/adapter/active_record_adapter_filter.rb, line 67
def not_nil_filter(memo, attr, value)
  if value == 'true' || value == true
    memo.where("#{string_style_attr(attr)} IS NOT NULL")
  else
    memo.where("#{string_style_attr(attr)} IS NULL")
  end
end

Private Instance Methods

attr_lookup(attr) click to toggle source
# File lib/quiver/adapter/active_record_adapter_filter.rb, line 77
def attr_lookup(attr)
  self.class.send(:attr_lookup_table)[attr]
end
hash_style_attr(attr, value) click to toggle source
# File lib/quiver/adapter/active_record_adapter_filter.rb, line 81
def hash_style_attr(attr, value)
  if table = attr_lookup(attr)
    {table => {attr => value}}
  else
    {attr => value}
  end
end
string_style_attr(attr) click to toggle source
# File lib/quiver/adapter/active_record_adapter_filter.rb, line 89
def string_style_attr(attr)
  if table = attr_lookup(attr)
    "#{table}.#{attr}"
  else
    attr
  end
end