Created
December 31, 2012 15:09
-
-
Save coffeeaddict/4420511 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# For future reference | |
# ActiveRecord | |
class Doc < ActiveRecord::Base | |
before_save do | |
# i am a proc, I have self as a reference to the object | |
self.attribute_x = nil | |
end | |
before_save { |x| | |
# i am a proc with 1 argument, x is the reference to the object | |
x.attribute = nil | |
} | |
before_save ->(x) { | |
# i am a Lambda with 1 argument... I am also Hartogs favorite notation | |
} | |
end | |
# The above all work as as expected | |
class RippleDoc | |
include Ripple::Document | |
before_save do | |
# i am the proc - I work | |
end | |
before_save do |x| | |
# i am a proc with argument, I do not work | |
end | |
before_save ->(x) { | |
# I am lambda, lambda, lambda. I function not | |
} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment