class Class
Public Instance Methods
class_attribute(*attrs)
click to toggle source
Provides a way to make class attributes that inherit. Pass in symbols for attribute names
# File lib/volt/extra_core/class.rb, line 4 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
remove_possible_method(method)
click to toggle source
Removes a method if it is defined.
# File lib/volt/extra_core/class.rb, line 22 def remove_possible_method(method) if method_defined?(method) || private_method_defined?(method) undef_method(method) end end