Skip to content

Instantly share code, notes, and snippets.

@luckyruby
Created March 24, 2014 22:16
Show Gist options
  • Save luckyruby/9750482 to your computer and use it in GitHub Desktop.
Save luckyruby/9750482 to your computer and use it in GitHub Desktop.
class Reports::Duplicates
include ActiveModel::Validations
include ActiveModel::Conversion
extend ActiveModel::Naming
attr_accessor :run_time, :conditions, :matches
def initialize(attributes = {})
self.run_time = Time.now
attributes.each {|name, value| send("#{name}=", value)}
self.conditions = []
self.matches = {}
construct_query
end
def persisted?
false
end
def run(options={})
end
private
def construct_query
end
def consolidate_conditions
if matches.empty?
self.conditions = conditions.join(" AND ")
else
self.conditions = [conditions.join(" AND ")] << matches
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment