class Person < ActiveRecord::Base
validates :terms_of_service, :acceptance => true
end
In the above, what is validates
from a Ruby standpoint? It's not a method definition, it's not a data definition or declaration. So, evidently it's a method invocation, right there in the body of the class. I have never seen a method invoked like that directly in a class (i.e. outside of a method definition), not even in the Ruby programming tutorial I'm going through now: http://ruby-doc.org/docs/ProgrammingRuby/.
So, if it's a method invocation, at what point is it being invoked? I tried the following as a test:
class Person
print "cat"
end
#p = Person.new
#q = Person.new
print "cat"
is being executed exactly once, regardless if any actual Person objects are being declared or not, so evidently just when parsing the class definition, Ruby sees the method print and says, "OK I will just go ahead and execute this now" but never does so again.
So, where is the Ruby documentation that will help me understand what is going on with validates
above?