[Rails] mattr_accessor inside a class
Rails extends Ruby with mattr_accessor (Module accessor). As Ruby's
attr_accessor generates getter/setter methods for instances,
mattr_accessor provide getter/setter methods at the module level. In
below example, you see that mattr_accessor declared in the class
context of LookupContext. It's declared in class, not module. However,
modules are defined in LookupContext, for example, the module
ViewPaths, which makes use of the accessor. So is it safe to say that
if a module accessor is declared in class, then it can only be
available to modules of that class?
class LookupContext
mattr_accessor :fallbacks
module ViewPaths
self.class.fallbacks.each do |resolver|
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home