module Asbestos::ClassCollection::ClassMethods

Public Instance Methods

class_collection(name, base = self) click to toggle source
# File lib/asbestos.rb, line 74
def class_collection(name, base = self)
  # this is a little nasty, the 'name' variable isn't available
  # in the scope of the eigenclass, so we have to class_eval
  # the eigenclass
  (class << base; self; end).instance_eval do
    extend ::Forwardable

    attr_accessor name
    def_delegators name, :[], :[]= if name == :all
  end

  Hash.new.tap do |hash|
    Asbestos.with_indifferent_access! hash
    base.instance_variable_set "@#{name}", hash
  end
end