I have a very basic question about Ruby which I can't seem to answer from browsing online:
property :currency, String
What does 'property' above mean? What circumstances should I use it under?
I have a very basic question about Ruby which I can't seem to answer from browsing online:
property :currency, String
What does 'property' above mean? What circumstances should I use it under?
As for many case in Rails, this is (most probably) a carefully disguised method call. Remember that in Ruby, parenthesis around method calls are options, so:
add(3, 4)
add 3, 4
are equivalent. So in your case,
property :currency, String
can actually be written as:
property(:currency, String)
So, a call to a method called "property" which takes two arguments, a Symbol and a Class. The method is most probably defined on a class from a library you are using.
property :currency, String
is a method call. When you find a line like that in a class then that means that a method property
is called with :currency
and String
as parameter.
For the special mean of this method, look at the docs