module QueueClassicPlus::InheritableAttribute

From github.com/apotonick/uber/blob/master/lib/uber/inheritable_attr.rb which is MIT license

Public Class Methods

inherit_for(klass, name) click to toggle source
# File lib/queue_classic_plus/inheritable_attr.rb, line 16
def self.inherit_for(klass, name)
  return unless klass.superclass.respond_to?(name)

  value = klass.superclass.send(name) # could be nil.
  Clone.(value) # this could be dynamic, allowing other inheritance strategies.
end

Public Instance Methods

inheritable_attr(name) click to toggle source
# File lib/queue_classic_plus/inheritable_attr.rb, line 4
def inheritable_attr(name)
  instance_eval %Q{
    def #{name}=(v)
      @#{name} = v
    end
    def #{name}
      return @#{name} if instance_variable_defined?(:@#{name})
      @#{name} = InheritableAttribute.inherit_for(self, :#{name})
    end
  }
end