Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Re: attr_protected macro
Tim Becker
3/16/2007 10:02:00 AM
> I was going through a blog where I found "Do this by calling the
> attr_protected macro in your model class definition" what do you mean
> by macro here.
> Is it a method?
Ruby comes with the `attr_accessor` family of functions built in to
`Module` (
http://www.ruby-doc.org/core/classes/M...
). These
methods allow you to specify which instance variables of a class you'd
like accessor methods you'd like getters and setters generated for
automatically. E.g.:
class Test
attr_accessor :test_variable
end
The above code will add roughly the following to the `Test` class:
def test_variable
@test_variable
end
def test_variable= a
@test_variable=a
end
The 'attr_...' methods are regular methods, but people might call them
"macros" because they're basically shorthand for generating other code
automatically. They're not macros in the C sense of the word.
I assume this is about rails, `attr_protected` refers to:
http://api.rubyonrails.org/classes/ActiveRecord/Base.ht...
-Tim
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Re: attr_protected macro
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password