module APIKey
  module ClassMethods
    attr_accessor :default_api_key
  end

  def self.included( klass )
    klass.extend ClassMethods
  end

  @default_api_key = nil

  attr_writer :api_key

  def api_key
    @api_key || self.class.default_api_key
  end
end

module APIKey
  module ClassMethods
    attr_accessor :default_api_key
  end

  def self.included( klass )
    klass.extend ClassMethods
  end

  attr_writer :api_key

  def api_key
    @api_key || self.class.default_api_key
  end
end

Remove class instance variable initalization.
Remove class instance variable initalization.

By default the variable will be nil until it is defined by the
setting of it. No need to make this explicit.
