Module: AmazonProductAdvertisingApi::CoreExtensions::Class
- Defined in:
- lib/amazon_product_advertising_api/support.rb
Instance Method Summary collapse
-
#cattr_accessor(sym) ⇒ Object
Pleasant syntax for Class attribute accessors.
-
#cattr_reader(sym) ⇒ Object
Pleasant syntax for Class attribute readers.
-
#cattr_writer(sym) ⇒ Object
Pleasant syntax for Class attribute writers.
Instance Method Details
#cattr_accessor(sym) ⇒ Object
Pleasant syntax for Class attribute accessors.
36 37 38 39 |
# File 'lib/amazon_product_advertising_api/support.rb', line 36 def cattr_accessor(sym) cattr_reader(sym) cattr_writer(sym) end |
#cattr_reader(sym) ⇒ Object
Pleasant syntax for Class attribute readers.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/amazon_product_advertising_api/support.rb', line 6 def cattr_reader(sym) class_eval(<<-EOS, __FILE__, __LINE__) unless defined? @@#{sym} # unless defined? @@hair_colors @@#{sym} = nil # @@hair_colors = nil end # end # def self.#{sym} # def self.hair_colors @@#{sym} # @@hair_colors end # end # def #{sym} # def hair_colors @@#{sym} # @@hair_colors end # end EOS end |
#cattr_writer(sym) ⇒ Object
Pleasant syntax for Class attribute writers.
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/amazon_product_advertising_api/support.rb', line 23 def cattr_writer(sym) class_eval(<<-EOS, __FILE__, __LINE__) unless defined? @@#{sym} # unless defined? @@hair_colors @@#{sym} = nil # @@hair_colors = nil end # end # def self.#{sym}=(obj) # def self.hair_colors=(obj) @@#{sym} = obj # @@hair_colors = obj end # end EOS end |