Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def method_missing(method_name, *args, &block)
- if method_name =~ /^swap_(.+)_with(!?)$/
- property = $1
- is_bang = $2 == '!'
- sibling = args[0]
- old_sibling_property = sibling.send(property)
- old_self_property = self.send(property)
- puts property
- sibling.send("#{propery}=", old_self_property)
- self.send("#{property}=", old_sibling_property)
- [self, sibling].collect(&:save) if is_bang
- return self
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement