Skip to content

Instantly share code, notes, and snippets.

@coffeeaddict
Created December 31, 2012 15:09
Show Gist options
  • Save coffeeaddict/4420511 to your computer and use it in GitHub Desktop.
Save coffeeaddict/4420511 to your computer and use it in GitHub Desktop.
# 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