Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
tag: v2.1.2
Fetching contributors…

Cannot retrieve contributors at this time

33 lines (27 sloc) 0.934 kB
class Module
# Declares an attribute reader backed by an internally-named instance variable.
def attr_internal_reader(*attrs)
attrs.each do |attr|
module_eval "def #{attr}() #{attr_internal_ivar_name(attr)} end"
end
end
# Declares an attribute writer backed by an internally-named instance variable.
def attr_internal_writer(*attrs)
attrs.each do |attr|
module_eval "def #{attr}=(v) #{attr_internal_ivar_name(attr)} = v end"
end
end
# Declares an attribute reader and writer backed by an internally-named instance
# variable.
def attr_internal_accessor(*attrs)
attr_internal_reader(*attrs)
attr_internal_writer(*attrs)
end
alias_method :attr_internal, :attr_internal_accessor
private
mattr_accessor :attr_internal_naming_format
self.attr_internal_naming_format = '@_%s'
def attr_internal_ivar_name(attr)
attr_internal_naming_format % attr
end
end
Jump to Line
Something went wrong with that request. Please try again.