Como a cadeia Rails ActiveRecord “where” clausa sem múltiplas consultas?

Eu sou um desenvolvedor PHP aprendendo o awesomness de Ruby on Rails, estou amando ActiveRecord e notei algo realmente interessante, que é como os métodos ActiveRecord detectam o fim da cadeia de método para executar a consulta.

@person = Person.where(name: 'Jason').where(age: 26)

# In my humble imagination I'd think that each where() executes a database query
# But in reality, it doesn't until the last method in the chain

Como esse feitiço funciona?

questionAnswers(4)

yourAnswerToTheQuestion