1 # Extends the module object with module and instance accessors for class attributes,
2 # just like the native attr* accessors for instance attributes.
4 # module AppConfiguration
5 # mattr_accessor :google_api_key
6 # self.google_api_key = "123456789"
8 # mattr_accessor :paypal_url
9 # self.paypal_url = "www.sandbox.paypal.com"
12 # AppConfiguration.google_api_key = "overriding the api key!"
14 def mattr_reader(*syms
)
16 next if sym
.is_a
?(Hash
)
17 class_eval(<<-EOS, __FILE__, __LINE__)
18 unless defined? @@#{sym}
33 def mattr_writer(*syms
)
34 options
= syms
.extract_options
!
36 class_eval(<<-EOS, __FILE__, __LINE__)
37 unless defined? @@#{sym}
49 " unless options[:instance_writer] == false }
54 def mattr_accessor(*syms
)