Refactor
:my
=>
'code'
Codes
Refactorings
Popular
Best
Submit
Spam
Account
Logout
Login
JavaScript doesn't seem to be activated, expect things to be ugly and sloppy!
Learn How to Create Your Own Programming Language
createyourproglang.com
Recent
How to get accepted in Fileice (200% Working) 22/2012
Premium Account
FILE HOSTS PREMIUM ACCOUNT
ALL FILE HOST PREMIUM ACCOUNTS
Zynga Slingo Trainer v5.12
iTunes Gift Card Generator V3.1 2012
Diablo 3 GOLD Coins FREE
Working PS3 Jailbreak 3.65 And 3.66
ExtaBit Premium Accounts and Cookies
Steam Wallet Hack - Money Adder & Hack v3
Popular
XBOX POINTS GENERATOR - MICROSOFT POINTS GENERATOR v1.2012
11 may 2012 premium uploading accounts 100% working
Free Microsoft Points
Free Microsoft Points - Microsoft Points Generator - Xbox Live Codes 2012
Car Town Free Blue Points Hack
Free CarTown Blue Points Generator and CarTown Templates
Better way to get content via jQuery $.get()
Free Microsoft Points
Simple Days Purger
Sharecash Downloader Bypass Surveys New 05/2012
Pastable version of
Merging two sets of conditions
<pre class='prettyprint' language='ruby'># Merges two sets of condition options for ActiveRecord::Base find calls def merge_conditions(base_conditions, new_conditions, boolean_operator="AND") return base_conditions if new_conditions.blank? return new_conditions if base_conditions.blank? case base_conditions when Hash case new_conditions when Hash base_conditions.merge(new_conditions) else raise "Hash conditions can only be merged with other hash conditions" end when Array case new_conditions when Array ["#{base_conditions[0]} #{boolean_operator} #{new_conditions[0]}", base_conditions[1..-1], new_conditions[1..-1]].flatten when String conditions = base_conditions.dup conditions[0] = "#{base_conditions[0]} #{boolean_operator} #{new_conditions}" conditions else raise "Array conditions can only be merged with array or string conditions" end when String case new_conditions when String "#{base_conditions} #{boolean_operator} #{new_conditions}" when Array conditions = new_conditions.dup conditions[0] = "#{base_conditions} #{boolean_operator} #{new_conditions[0]}" conditions else raise "String conditions can only be merged with string or array conditions" end end end</pre> <a href="http://www.refactormycode.com/codes/84-merging-two-sets-of-conditions" style="color:#fff" title="As seen on RefactorMyCode.com"><img alt="Small_logo" src="http://www.refactormycode.com/images/small_logo.gif" style="border:0" /></a>