"require" gives you methods that appear out of nowhere (unlike other language where they are name spaced), method call without perens (so what is an attribute, what is a method call)
All of these look nice at first but kills maintainability later
"require" gives you methods that appear out of nowhere (unlike other language where they are name spaced), method call without perens (so what is an attribute, what is a method call)
All of these look nice at first but kills maintainability later
That's known as Uniform Access Principle[0] and is a wonderful feature to have.
Ruby is far less magical today than it was 5-10 years ago. Magic is a clever word for "I don't understand this thing yet."
0 - http://martinfowler.com/bliki/UniformAccessPrinciple.html
In the contexts I usually see, the complaints of magic are regarding Ruby's fondness of Spooky Action at a Distance. I would then argue that Ruby or its frameworks do seem to rely too much on this "magic" that otherwise is condemned by recent literature (and Code Complete).
Now Rails on the other hand relies on a good deal more magic than say Django, but it's recognized in the community as a tradeoff and it is done carefully. Some of the things that rubyists accept in Rails they would never put in an application or library because it is deemed okay only by massively adopted convention at the framework level, but not generally a good practice.
Then you have libraries like rspec which started out being full of magic but which gradually got refined and cleaned up so that in rspec 3.0 you have zero monkey patches; it's just pure ruby, providing a totally modular set of DSLs that work together nicely and allow for amazingly readable test output.
It's all method calls. Attributes don't really exist.
Probably nitpicking, but it's actually all messages. An object might not have a method "foo", but happily respond to the "foo" message.
The difference is whether we're discussing the invocation or the response. OP's usage of method isn't incorrect in this case if it's discussing the response. It is true that all message responses (including accessors) are implemented using methods.
An object can respond to a message even though it doesn't have a method with that name. A classic example are Rails' dynamic finders:
User.methods.include?(:find_by_name)
=> false
User.respond_to?(:find_by_name)
=> trueSure, by using a different method (method_missing); its still all method calls.
I always worry about this too, but in practice I've rarely run into a namespace collision (I can't even remember the last time it happened.)