module DataMapper::Sweatshop::ClassAttributes
Public Class Methods
accessor(klass, *attributes)
click to toggle source
# File lib/dm-sweatshop/support/class_attributes.rb, line 40 def self.accessor(klass, *attributes) self.reader(klass, *attributes) self.writer(klass, *attributes) end
reader(klass, *attributes)
click to toggle source
# File lib/dm-sweatshop/support/class_attributes.rb, line 4 def self.reader(klass, *attributes) attributes.each do |attribute| klass.class_eval(<<-RUBY, __FILE__, __LINE__ + 1) unless defined? @@#{attribute} @@#{attribute} = nil end def self.#{attribute} @@#{attribute} end def #{attribute} @@#{attribute} end RUBY end end
writer(klass, *attributes)
click to toggle source
# File lib/dm-sweatshop/support/class_attributes.rb, line 22 def self.writer(klass, *attributes) attributes.each do |attribute| klass.class_eval(<<-RUBY, __FILE__, __LINE__ + 1) unless defined? @@#{attribute} @@#{attribute} = nil end def self.#{attribute}=(obj) @@#{attribute} = obj end def #{attribute}=(obj) @@#{attribute} = obj end RUBY end end