1

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?

RPV
  • 397
  • 1
  • 5
  • 16

2 Answers2

0

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.

Martin
  • 7,634
  • 1
  • 20
  • 23
  • thank for clarifying martin. It's indeed a method, but as defined by the second link provided by Bibek Sharma above. – RPV Nov 27 '15 at 09:29
0

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

spickermann
  • 100,941
  • 9
  • 101
  • 131