Created
May 29, 2015 13:12
-
-
Save johnpmitsch/a59ee6efacc8d752b2b2 to your computer and use it in GitHub Desktop.
Content View Version
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def self.find_by_version(key, operator, value) | |
major, minor = value.to_s.split('.') | |
if minor.nil? or /[<>]/ =~ operator | |
query = where("major #{operator} ?", major) | |
else | |
query = where("major #{operator} ? and minor #{operator} ?", major, minor) | |
end | |
_, conditions = query.to_sql.split("WHERE") | |
{ :conditions => conditions } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment