Jason (jcreed) wrote,
Jason
jcreed

Still chugging through rails tut.
WHAT SORCERY IS THIS.
irb> User.methods.select{|x| /^find/.match x.to_s}
=> [:finder_needs_type_condition?, :find, :find_each, :find_in_batches, :find_by_sql]
irb> User.find_by_email("asdf")
  User Load (0.2ms)  SELECT "users".* FROM "users" WHERE "users"."email" = 'asdf' LIMIT 1


The surprising thing is that there is no method named "find_by_email", yet there is a method named find_by_email. There's some sort of fallback reflectiony autoload method-dispatch intervention thingy that lets you do arbitrary magic things, isn't there? Sigh.

Grumbling about that aside, I reeeally like this concrete syntax for function expressions. Holy dang.
Tags: ruby
Subscribe

  • (no subject)

    Some further progress cleaning up the https://xkcd.com/1360/ -esque augean stables that is my hard drive. Tomato chicken I made a couple days ago…

  • (no subject)

    Did some personal archaeology. Helped a little with laundry. Threw some chicken, onions, tomato, stock, peppers in the slow cooker and hopefully…

  • (no subject)

    Dinner with akiva and dannel at nuevo portal in carroll gardens. Ate a pile of chicken stew and rice and beans and maduros, good times. I do miss…

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 14 comments

  • (no subject)

    Some further progress cleaning up the https://xkcd.com/1360/ -esque augean stables that is my hard drive. Tomato chicken I made a couple days ago…

  • (no subject)

    Did some personal archaeology. Helped a little with laundry. Threw some chicken, onions, tomato, stock, peppers in the slow cooker and hopefully…

  • (no subject)

    Dinner with akiva and dannel at nuevo portal in carroll gardens. Ate a pile of chicken stew and rice and beans and maduros, good times. I do miss…