instance method
mattr_reader
Ruby on Rails 4.0.13
Since v2.2.3Signature
mattr_reader(*syms)
No documentation comment.
Parameters
-
symsrest
Source
# File activesupport/lib/active_support/core_ext/module/attribute_accessors.rb, line 4
def mattr_reader(*syms)
options = syms.extract_options!
syms.each do |sym|
raise NameError.new('invalid attribute name') unless sym =~ /^[_A-Za-z]\w*$/
class_eval(<<-EOS, __FILE__, __LINE__ + 1)
@@#{sym} = nil unless defined? @@#{sym}
def self.#{sym}
@@#{sym}
end
EOS
unless options[:instance_reader] == false || options[:instance_accessor] == false
class_eval(<<-EOS, __FILE__, __LINE__ + 1)
def #{sym}
@@#{sym}
end
EOS
end
end
end
Defined in activesupport/lib/active_support/core_ext/module/attribute_accessors.rb line 4
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in Module