Sha256: 56c92331f080a428368ccd9c97c3acc0047a84943c0fc07fc16ce1416dfe098f
Contents?: true
Size: 639 Bytes
Versions: 50
Compression:
Stored size: 639 Bytes
Contents
class Class # Provides a way to make class attributes that inherit. Pass # in symbols for attribute names def class_attribute(*attrs) attrs.each do |name| define_singleton_method(name) { nil } ivar = "@#{name}" define_singleton_method("#{name}=") do |val| singleton_class.class_eval do remove_possible_method(name) define_method(name) { val } end val end end end # Removes a method if it is defined. def remove_possible_method(method) if method_defined?(method) || private_method_defined?(method) undef_method(method) end end end
Version data entries
50 entries across 50 versions & 1 rubygems