daily pastebin goal
41%
SHARE
TWEET

Untitled

a guest Mar 9th, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.   def method_missing(method_name, *args, &block)
  2.     if method_name =~ /^swap_(.+)_with(!?)$/
  3.       property = $1
  4.       is_bang  = $2 == '!'
  5.       sibling  = args[0]
  6.  
  7.       old_sibling_property = sibling.send(property)
  8.       old_self_property    = self.send(property)
  9.       puts property
  10.       sibling.send("#{propery}=", old_self_property)
  11.       self.send("#{property}=", old_sibling_property)
  12.  
  13.       [self, sibling].collect(&:save) if is_bang
  14.       return self
  15.     end
  16.   end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top